3 ms·
If Objective-C fits your definition of statically typed OO language, then I believe you can return whatever you want in the -(id)init constructor. The common i
by 0x0 15y ago
If Objective-C fits your definition of statically typed OO language, then I believe you can return whatever you want in the -(id)init constructor.
The common idiom for implementing constructors in subclasses is to do "self = [super init]; if (self) { ... subclass constructor impl ... }; return self".
Setting self to nil is a common use-case.
- ryanpetrich 15y agoObjective-C isn't a statically typed language, it is a dynamically typed one with static type annotations to make the compiler check common errors for you.