Posterous
Doron is using Posterous to post everything online. Shouldn't you?
Web_thumb
 
View Doron Katz's profile on LinkedIn

Objective-C: EXC_BAD_ACCESS

Just a quick XCode/Objective-C pointer, for those of you who happen to come across the familiar console error EXC_BAD_ACCESS.  I will be working on an overview tutorial regarding Memory Management, but for now, this quick set of notes would help you generally understand memory issues you may come across and feel stumped!

The  EXC_BAD_ACCESS  that you may get, usually arises from over-releasing an object, and so when you are debugging you may not have noticed that as it crashes deep in the framework stack, when none of your code is visible. 
To combat such problems you must follow the Cocoa Memory Management Guidelines and Apple have some good documentation on that (in fact better than most third-party literature I come across). 
Things to Remember
  • You are only responsible for releasing an object from memory when:
    • you directly have allocated (ALLOC), copy or retain that object, you may proceed with release ing or autorelease ing it. Otherwise, it's not your duty to release.
  • If you need to store a returned object in an instance object you have (i.e self.varName),  you must Retain or Copy it before releasing it. ( I will discuss this more in a future blog post).
  • If you instantiate an object using a convenience method i.e :
 NSString *userPart= [[emailAddress.text componentsSeparatedByString:@"@"] objectAtIndex:0];  
Filed under: iPhone Dev
0 comments

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     Connect     twitter