Reputation: 12597
What code is correct and why ?
- (void)viewDidLoad
{
/*my code
*/
[super viewDidLoad];
}
or
- (void)viewDidLoad
{
[super viewDidLoad];
/*my code
*/
}
Upvotes: 1
Views: 72
Reputation: 3054
It doesn't really matter that much. It's more about the way you'd like it. Would you want the super
to respond first or the self
? If it doesn't really matter that hard, do what you like.
Upvotes: 1
Reputation: 1020
I'd say the latter. You want your superclass's code to run first before you run your own.
Or, if you're completely replacing the function, you'd just comment out the call to the superclass's implementation.
Upvotes: 0
Reputation: 2198
It depends on whether you want your subclasses code to execute before or after the superclasses code for that method. I would say it's more common to do your own custom code after the call to super so that your subclasses code follows the superclasses code. Again, it depends on exactly what your trying to do.
Upvotes: 0