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]; 
This entry was posted in General and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s