When should I call super?

The usual rule of thumb is that when you are overriding a method that does some kind of initialization, you call super first and then do your stuff. And when you override some kind of teardown method, you call super last:

- (void) setupSomething {
    [super setupSomething];
    …
}

- (void) tearDownSomething {
    …
    [super tearDownSomething];
}

The first kind are methods like init…, viewWillAppear, viewDidLoad or setUp. The second are things like dealloc, viewDidUnload, viewWillDisappear or tearDown. This is no hard rule, it just follows from the things the methods do.

Leave a Comment