This is considered typical
- (id)init {
self = [super init];
if (self) {
// <#initializations#>
}
return self;
}
Returning nil
is the appropriate thing to do. Part of the reason that sending any message to nil is allowed and defined to return nil as a result is that you can build compound statements like:
resultObject = [[[[class alloc] init] autorelease] someProperty];
That statement executes all the way through even if any individual method call returns nil. To fit with that, the init
convention is to return the nil if the superclass does so.
As JustSid points out, ObjC uses exceptions only for unrecoverable problems.