Re: Should a Method set NSError* to nil when No Error?
Re: Should a Method set NSError* to nil when No Error?
- Subject: Re: Should a Method set NSError* to nil when No Error?
- From: Uli Kusterer <email@hidden>
- Date: Sun, 20 Apr 2008 01:03:45 +0200
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.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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