Re: odd behavior with NSError?
Re: odd behavior with NSError?
- Subject: Re: odd behavior with NSError?
- From: Kyle Sluder <email@hidden>
- Date: Thu, 15 Oct 2009 22:57:27 -0700
On Thu, Oct 15, 2009 at 10:41 PM, Nathan Vander Wilt
<email@hidden> wrote:
> Ouch. So the following pattern is incorrect?
>
> NSError* internalError = nil;
> (void)[foo somethingReturningBool:bar error:&internalError];
> if (internalError) {
Indeed, this is very incorrect. If the existence of the NSError
object were intended to be the indication of an error, the methods
would just return NSErrors rather than BOOLs.
> I got into this habit because most every method is documented to say things
> like "parameter used if an error occurs" and "May be NULL". You're saying
> that some methods go out of their way to trample my (potentially
> unavailable) error storage even on success? I'm starting to worry that I'll
> spend tomorrow fixing much old code instead of getting to make new
> mistakes...
In fact they do. AppKit *loves* to do this. We've filed Radars on
the cases where it does.
But your use of the error object as indication of failure is misguided
and is your bug, not Apple's.
--Kyle Sluder
_______________________________________________
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