Re: Newbie OOP style question
Re: Newbie OOP style question
- Subject: Re: Newbie OOP style question
- From: Scott Ellsworth <email@hidden>
- Date: Thu, 11 May 2006 18:07:43 -0700
On May 11, 2006, at 5:48 PM, mmalcolm crawford wrote:
On May 11, 2006, at 5:37 PM, Tim Gray wrote:
On 5/11/06, Pierce T. Wetter III wrote:
But really, its just a matter of practice with the idiom:
1. Did you call init? Better call release/autorelease somewhere.
2. Did you get the object from someone else and you need to keep
it around? better call [retain].
3. call [instanceObj release] on every instance variable in your
dealloc method.
This is incomplete.
Per the list guidelines, please don't reformulate the memory
management rules in mail messages. The canonical rules are given
in the documentation:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
MemoryMgmt/Tasks/MemoryManagementRules.html#//apple_ref/doc/uid/
20000994>
I strongly encourage all new Cocoa developers to download
Accessorizer at <http://www.kevincallahan.org/software/
accessorizer.html>. It automates the creation of rule-compliant
accessors for your data, which radically reduces the chance of memory
leaks.
Further, if you examine and understand all of the options it has for
accessor generation, you probably have a good grasp of how memory
management works in Cocoa.
Thanks for this. I will print it out and tape it up next to
monitor until I get it straight. I was planning on rereading the
chapters on reference counting, retaining, and releasing tonight -
I guess thats definitely a good idea.
Memory management is fundamental to Cocoa. Reading the relevant
documentation and understanding the rules should be considered
essential.
Seconded! This is one of the areas that new Cocoa programmers have
the hardest time with.
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden