• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OBJC newbie] - Intance variable becomes 'invalid'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OBJC newbie] - Intance variable becomes 'invalid'


  • Subject: Re: [OBJC newbie] - Intance variable becomes 'invalid'
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 31 May 2006 17:06:22 -0400

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

_______________________________________________
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


References: 
 >Re: Re: Re: [OBJC newbie] - Intance variable becomes 'invalid' (From: Graham <email@hidden>)

  • Prev by Date: Re: [OBJC newbie] - Intance variable becomes 'invalid'
  • Next by Date: Re: behind the scenes of -drawInRect:
  • Previous by thread: Re: [OBJC newbie] - Intance variable becomes 'invalid'
  • Next by thread: Change window contents at runtime?
  • Index(es):
    • Date
    • Thread