FROM : Sherm Pendley
DATE : Wed May 31 23:06:22 2006
On May 31, 2006, at 4:14 PM, Graham wrote:
> Thanks for all the feedback on this.
> It's just a learning curve I guess.
> It just reminds me of how things used to be about 12 years ago when
> I last did any C or C++. I've been doing nothing but Java since
> that point and have forgotten all about the need to consider memory
> management.
Don't worry - it's not *that* big a deal. As far as I've seen, the
two biggest stumbling blocks are easily avoided:
1. Over-thinking it. Newbies tend to think it's more difficult than
it really is, and keep asking "but what about..." Just keep the
"cardinal rules" in mind, and you'll be fine. They're applied very
consistently, and exceptions are clearly documented.
2. Generally, if you need to retain an object beyond the scope of
the current event, that means storing it in an instance variable. A
common mistake is to retain and set the value of the ivar directly.
This leads to retains and releases being sprinkled all over the place
- small wonder it gets confusing. A better approach is to isolate the
memory management into accessor methods. There are even tools like
"Accessorizer" that can write those methods for you.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
DATE : Wed May 31 23:06:22 2006
On May 31, 2006, at 4:14 PM, Graham wrote:
> Thanks for all the feedback on this.
> It's just a learning curve I guess.
> It just reminds me of how things used to be about 12 years ago when
> I last did any C or C++. I've been doing nothing but Java since
> that point and have forgotten all about the need to consider memory
> management.
Don't worry - it's not *that* big a deal. As far as I've seen, the
two biggest stumbling blocks are easily avoided:
1. Over-thinking it. Newbies tend to think it's more difficult than
it really is, and keep asking "but what about..." Just keep the
"cardinal rules" in mind, and you'll be fine. They're applied very
consistently, and exceptions are clearly documented.
2. Generally, if you need to retain an object beyond the scope of
the current event, that means storing it in an instance variable. A
common mistake is to retain and set the value of the ivar directly.
This leads to retains and releases being sprinkled all over the place
- small wonder it gets confusing. A better approach is to isolate the
memory management into accessor methods. There are even tools like
"Accessorizer" that can write those methods for you.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org






Cocoa mail archive

