Does the method use NSObject init?

Does it make sense to write self = [super init];in a custom initialization method when subclassing NSObject? I know this is necessary when subclassing any other class, since it can have custom initialization, but does the NSObject init method do nothing?

+5
source share
1 answer

The object is not ready for use until it is initialized. The method initdefined in the class NSObjectdoes not initialize; it just returns self.

So basically you don’t have to call [super init]in a subclass NSObject, but I would recommend it. It is simply the best design. If you change the superclass, it will still work.

Source: Link to the NSObject class .

+9
source

All Articles