Typically when I subclass from a UI class I will call the superclass initializer of interest. However, I’m not sure of the implementation details of NSObject, and it seems like there’s not much going on in terms of member vars, so I wonder: do I need to call [super init] if my subclass extends NSObject?
Typically when I subclass from a UI class I will call the superclass initializer
Share
Technically, no. The documentation for
-[NSObject init]says thatBecause it is documented and there’s probably already a bunch of code that relies on it, that fact is highly unlikely to change in future versions of Mac OS X.
Edit: BoltClock’s a Unicorn brings up a point that I would like to make more hyperbolic: the total time saved by not calling
-[NSObject init]for everyone ever running your program is unlikely to ever exceed the debugging time that you’d incur if you ever change the superclass for your class to something other thanNSObjectand forget to add a call to[super init].