I know this has been discussed previously, in this question for instance: In Objective-C why should I check if self = [super init] is not nil?
- (instancetype)init
{
self = [super init]; // Is potentially nil
if (self)
{
// Initialization code here…
}
return self;
}
I understand that self
might be nil
, but why does that matter? All answeres I've seen just say that self
might be nil
but do not explain why it matters. If you send a message to nil
nothing will happen. You don't nil-check in any other code (except in some cases) so why do you need to do it in init
?