• 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: Should a Method set NSError* to nil when No Error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should a Method set NSError* to nil when No Error?


  • Subject: Re: Should a Method set NSError* to nil when No Error?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 20 Apr 2008 11:45:15 +0200


Le 20 avr. 08 à 01:03, Uli Kusterer a écrit :

Am 19.04.2008 um 18:46 schrieb Jerry Krinock:
I often write methods that take an (NSError**)error_p argument. In the documentation of Apple methods that do this, I read that the NSError** will be set if there ^is^ an error, but most do not specify what will happen if there is ^not^.


Well, when Apple code doesn't specify it will be set to NIL, one can't rely on that, so definitely rely on the return value for those.

However, when I write my own code, I like to set the error variable on NIL to indicate no error, because that's just better style. Then again, I also initialize list counters in code like:

	int x = 0;
	for( x = 0; x < maxCount(); x++ )
		;

Simply because you'll never know who is going to insert their own code between those two lines and re-use x. Even if you work alone, you may screw up two years from now.

I greatly prefere the C99 way to do it. It prevents variables conflict if you have more than one loop in your method.


for (int idx = 0; idx < maxCount(); idx++) {

}

_______________________________________________

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: Should a Method set NSError* to nil when No Error?
      • From: Uli Kusterer <email@hidden>
References: 
 >Should a Method set NSError* to nil when No Error? (From: Jerry Krinock <email@hidden>)
 >Re: Should a Method set NSError* to nil when No Error? (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Extending NSOpenGLView leads to strange compile error...
  • Next by Date: Re: My private problems
  • Previous by thread: Re: Should a Method set NSError* to nil when No Error?
  • Next by thread: Re: Should a Method set NSError* to nil when No Error?
  • Index(es):
    • Date
    • Thread