Proper way to throw an exception in an iOS application...
Proper way to throw an exception in an iOS application...
- Subject: Proper way to throw an exception in an iOS application...
- From: Brian Lambert <email@hidden>
- Date: Sat, 17 Mar 2012 13:19:39 -0700
Happy Coding Saturday!
Regarding iOS / OS X exception throwing.
One camp says to use:
[NSException raise:NSInvalidArgumentException format:@"pageIndex is out of range"];
Which I was first exposed to and have been using.
This doesn't seem to be ideal, though, because the compiler doesn't recognize that this represents a throw and sometimes you wind up with the awkward: "Control may reach end of non-void function" case and have to code something like:
[NSException raise:NSInternalInconsistencyException format:@"Mumblefart can't be somethingorothered"];
return nil; // Can't actually get here. Awkward Code...
It would seem, then, that using @throw would be superior:
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"pageIndex is out of range" userInfo:nil];
But it doesn't seem to be highly used in code I'm reading.
I'm leaning towards switching to @throw.
How do the awesomest engineers do this? Your thoughts?
Best,
Brian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden