• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: odd behavior with NSError?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: odd behavior with NSError?


  • Subject: Re: odd behavior with NSError?
  • From: Nathan Vander Wilt <email@hidden>
  • Date: Thu, 15 Oct 2009 22:41:57 -0700

On Oct 2, 2009, at 7:45 AM, Bill Bumgarner wrote:
In either case, assuming the undefined reference is nil would be a bug. Initializing the variables to nil prior to the call isn't going to change anything in that regard.

(And, yes, there are methods that modify their error parameter on success -- purely an implementation detail. Perfect valid thing to do since the return value is undefined on success.)

Ouch. So the following pattern is incorrect?

NSError* internalError = nil;
(void)[foo somethingReturningBool:bar error:&internalError];
if (internalError) {
    // ...
}

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...

thanks,
-natevw
_______________________________________________

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


  • Follow-Ups:
    • Re: odd behavior with NSError?
      • From: mmalc Crawford <email@hidden>
    • Re: odd behavior with NSError?
      • From: Kyle Sluder <email@hidden>
    • Re: odd behavior with NSError?
      • From: Bill Bumgarner <email@hidden>
References: 
 >Re: odd behavior with NSError? (From: Gregory Weston <email@hidden>)
 >Re: odd behavior with NSError? (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: How to detect and disable/delay sleep event in cocoa for some critical threads to complete
  • Next by Date: Re: odd behavior with NSError?
  • Previous by thread: Re: odd behavior with NSError?
  • Next by thread: Re: odd behavior with NSError?
  • Index(es):
    • Date
    • Thread