Wondering what the point of if (self = [super ... in the following code is? What scenario is it trying to protect against?
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// STUFF CONFIGURED HERE
}
return self;
}
Taken from here.
It is protecting against the super implementation returning nil. If the superclass decides that it can’t initialize the object, it could release it and return nil, which would then crash the program if you tried to do any initialization because you are trying to dereference a nil pointer.