On Sat, Oct 10, 2009 at 12:21 PM, Shawn Erickson <shaw...@gmail.com> wrote:
>
> Anyway the amount of code you have posted leave to much out to understand
> all that may be wrong with your memory management.

The code does show one common anti-pattern - calls to -retain and
-release that should be hidden in an accessor method.

Each instance variable that refers to an object should have a
setVariable: setter method that properly releases the old value and
retains the new value. Encapsulating the memory-management code makes
it far easier to debug - scattering it throughout your code leads to
torn hair and madness.

It's also good OOP; when you find yourself repeating some code around
access to an instance variable, it's often a good idea to factor the
repetitious code into accessor methods. That makes the repeated code
easier to manage, and leaves less clutter in the calling code.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to