Re: Unable to disassemble objc_assign_strongCast
Re: Unable to disassemble objc_assign_strongCast
- Subject: Re: Unable to disassemble objc_assign_strongCast
- From: Roland King <email@hidden>
- Date: Tue, 03 Nov 2009 14:06:37 +0800
Important nitpick:
NSError *saveError = nil;
[importContext save:&saveError];
Methods that follow the NSError** convention are not required to
actually assign a value to the saveError pointer, so you'll want to
make sure to initialize saveError to nil since its a local variable.
Wouldn't want to be checking against undefined garbage later,
especially if you have something like a "if (saveError)" check.
- Bryan
_______________________________________________
Haven't there been several threads recently telling people *never* to
use the if( saveError ) check because saveError may be set even if the
method succeeds.
if the save: method returns NO, which is what you should check, is the
saveError then not guaranteed to be assigned?
if( ![ importContext save:&saveError ] )
{
// use saveError as you please.
}
Not that I particularly disagree with setting variables explicitly to
nil or NULL, it's a good practice, however the use case you give, of
checking it later to see if there was an error, seems wrong.
_______________________________________________
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