Sunday, September 20, 2009

Cocoa(touch) memory management is as easy as 1-2-3

There is a common misconception that Cocoa memory management is hard. It's not.

  1. Use auto-generated accessors religiously
  2. Release your instance variables in dealloc
  3. Always use convenience methods to create objects
Wow, that wasn't too hard!

3 comments:

Anonymous said...

If anything, the author of the linked article's use of the phrase, "iPhone and iTouch Frameworks" is indicative of her lack of understanding.

Even with the complete set of memory management rules taken into consideration, it is very straightforward:

Simple Rules for Memory Management

I believe what catches many people off guard is it forces the developer to think. God forbid a developer has to think about the code he's writing.

retainCount

Marcel Weiher said...

Well, I have to admit that I'd also rather not have to think about mechanical things, things that the computer could do for me.

Following the 3 steps, I don't have to think about memory management, because those steps take care of the "Simple Rules".

Olivier Refalo said...

no doubts, it's easier than java, .net, python an php allocations altogether...

-> you read me right, it's ERROR PRONE