Is returning nil from a [[class alloc] init] considered good practice?
问题 And is it a common idiom in Objective-C. I've only seen this used on [[NSImage alloc] initWithContentsOfFile: str] and it always make me think there is a memory leak, because i called alloc and the mantra is: "Call alloc and you must call release" - unless its one of the cases where you don't need to. 回答1: It is a common idiom to indicate a error in initializing the object. You are correct, however, the allocated instance must be released. So the pattern would be - (id)init { self = [super