• 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: NSError: why returned directly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSError: why returned directly?


  • Subject: Re: NSError: why returned directly?
  • From: j o a r <email@hidden>
  • Date: Wed, 26 Apr 2006 11:54:08 +0200


On 26 apr 2006, at 07.11, Scott Anguish wrote:

The way that NSErrors are typically returned is by-reference parameters .

I think that Ondra is well aware of this, and that his question is more on _why_ it is this way.


I agree with Ondra in that I think that it's a bit unfortunate that we start to see this "withError:(NSError **)outError" suffix on so many new methods in Cocoa. I really like that we get a formalized way to return error objects, but I don't particularly like the way it's implemented. A couple of reasons:

1) You have to change all method signatures
2) It's very easy to make mistakes when you return objects via by- reference parameters
3) By-reference parameters are difficult for newbies, and not "in the spirit" of Cocoa [*]


Why not use a global per-thread variable to store the current NSError instead of returning it as a parameter (like errno in C libraries)?

j o a r

[*] What percentage of methods - in all of Cocoa - used by-reference parameters before the introduction of NSError?

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSError: why returned directly? (From: Ondra Cada <email@hidden>)
 >Re: NSError: why returned directly? (From: Scott Anguish <email@hidden>)

  • Prev by Date: subclass NSSlider and NSSliderCell
  • Next by Date: Re: Trying to read PICT data using Quartz functions
  • Previous by thread: Re: NSError: why returned directly?
  • Next by thread: Re: NSError: why returned directly?
  • Index(es):
    • Date
    • Thread