As in the title, I was wondering what is the "default" implementation of viewDidLoad
in UIViewController
? Does it really do anything? Also does it matter if in my UIViewController's
subclass I write
-(void)viewDidLoad{
[super viewDidLoad];
/*custom code here*/
}
or
-(void)viewDidLoad{
/*custom code here*/
[super viewDidLoad];
}
?
P.S. This is not a duplicate, in other questions people ask when should they call [super viewDidLoad], while my main concern is what the UIViewController's implementation do with it.
That implementation does nothing, and can safely be removed if you have no setup to do after the view loads. However, it is fairly rare to have no custom setup to do here; this is the place where your view controller is telling you that all of its UI objects are available to customize with data. It's included in the template with an empty implementation as a reminder: here's where to do this.
As far as when to call super
: the general expectation is that setup or initialization methods call super
before doing work, and teardown methods call super
after doing work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With