Skip navigation.
 
mlRe: [OBJC newbie] - Intance variable becomes 'invalid'
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

Related mailsAuthorDate
ml[OBJC newbie] - Intance variable becomes 'invalid' Graham May 31, 20:51
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Moray Taylor May 31, 20:54
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' John Stiles May 31, 20:54
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Chas Spillar May 31, 20:56
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Robert Walker May 31, 20:58
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Chas Spillar May 31, 20:59
mlRe: Re: [OBJC newbie] - Intance variable becomes 'invalid' Graham May 31, 21:15
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Joshua Pennington May 31, 21:36
mlRe: Re: [OBJC newbie] - Intance variable becomes 'invalid' Shawn Erickson May 31, 21:55
mlRe: Re: Re: [OBJC newbie] - Intance variable becomes 'invalid' Graham May 31, 22:14
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Scott Ellsworth May 31, 22:46
mlRe: [OBJC newbie] - Intance variable becomes 'invalid' Sherm Pendley May 31, 23:06