Re: EXC_BAD_ACCESS in a Core Data application
Re: EXC_BAD_ACCESS in a Core Data application
- Subject: Re: EXC_BAD_ACCESS in a Core Data application
- From: Rippit the Ogg Frog <email@hidden>
- Date: Fri, 04 Sep 2009 11:55:42 -0700
Eric Hermanson wrote:
3. Attempting to access or return a local variable that has not been
initialized (although you may get a segmentation fault instead of a
BAD_ACCESS, I can't remember). For example,
- (BOOL)someMethod
{
BOOL returnValue;
// code in the method that never sets the returnValue to anything
return returnValue; // this is bad.
}
That's not really the best example. If someMethod returns a BOOL, than
no matter what value happens to occupy the memory that returnValue is
placed into, it will always be taken as true or false. It might not do
the right thing, but won't be likely to cause a crash.
A better example of code that would cause a crash is to return either an
uninitialized pointer, or a pointer to a struct that is a local variable.
--
Rippit the Ogg Frog
email@hidden
http://www.oggfrog.com/
_______________________________________________
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