Why not throw an exception if [super init] returns nil?

Viewed 3219

This is considered typical

- (id)init {
    self = [super init];
    if (self) {
        // <#initializations#>
    }
    return self;
}

but wouldn't it be better to go with something like this which actually responds appropriately?

- (id)init {
    self = [super init];
    if (self) {
        // <#initializations#>
    } else {
       @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"you think your constructor is executing, but it's not"] userInfo:nil]
    }
    return self;
}


The corollary to this question is, "under what conditions would [super init] return nil and shouldn't you handle that in the init method?"

4 Answers
Related