Is there a sure-fire way to know when it is necessary to call super in an
override?
Sample code shows that calling super is necessary for methods such as
-(id)init
- (void)windowControllerDidLoadNib
but not for
(NSData *)dataOfType
(BOOL)readFromData
How can you know for sure?
This
Is there a sure-fire way, no. It’s usually fairly clear however. Normally you
call super if you override a method unless it tells you not to in the
documentation or you are clearly trying to make something NOT do what the
superclass did. I suppose my handwaving rule is if a method ‘does’
On Tue, 12 Aug 2014 13:02:54 +, McLaughlin, Michael P. said:
Is there a sure-fire way to know when it is necessary to call super in
an override?
Checking the docs is best, but sometimes the compiler will warn you if you fail
to call super, if the method was tagged with NS_REQUIRES_SUPER.