Does it make sense to write self = [super init]; in a custom initialisation method while subclassing NSObject? I know it’s necessary when subclassing any other class, because it might have a custom initialisation, but does the NSObject init method do anything?
Does it make sense to write self = [super init]; in a custom initialisation
Share
An object isn’t ready to be used until it has been initialized. The
initmethod defined in theNSObjectclass does no initialization; it simply returns self.So basically you don’t necessarily have to call
[super init]in anNSObjectsubclass, but I still would recommend it. It’s simply a better design. If you change the superclass it will still work.Source: NSObject Class Reference.