Handling [super init] returning nil
Handling [super init] returning nil
- Subject: Handling [super init] returning nil
- From: Peter Teeson <email@hidden>
- Date: Wed, 29 May 2013 12:36:09 -0400
In Apple's Concepts in Objective-C Programming discussing Issues with Initializers there is this code snippet
id anObject = [[MyClass alloc] init];
if (anObject) {
[anObject doSOmething];
// more messages…
} else {
// handle error
}
All the code I Googled does not address the nil case in an error handling way. What one sees is mostly just returning nil.
In the interest of writing correct code I am curious to know the norm for handling such an error?
Use NSAssert and/or assert and friends?
Just log it?
Put up a Dialog ?
TIA for your thoughts.
Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden