views:

116

answers:

1

In Xcode, a lot of the auto-generated class files (especially those for UIViewController subclasses) will include methods that resemble the following:

- (void)dealloc {
    [super dealloc]
}

To me, this seems fairly pointless - if all a method is going to do is call super, why have it at all? Is there a purpose to these methods being generated?

+10  A: 

The default template code defines methods that are meant to be filled out with your customized code. The calls to super are there to remind you to make the call. The generated code is not meant to be a finished application. Think of the call to super as similar to the empty class definitions. You fill out the classes and therefore fill out the methods definitions

ennuikiller
Agreed. The -dealloc method is particularly important, since you need to release instance variables when the object is deallocated. The stub acts as a useful reminder for that step, so you don't leak memory.
Quinn Taylor