• 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: Memory Management and @synthesized accessors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management and @synthesized accessors


  • Subject: Re: Memory Management and @synthesized accessors
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 21 Feb 2009 20:26:23 +0100


Le 21 févr. 09 à 19:39, Stuart Malin a écrit :

I've seen the idiom [[property retain] autorelease] used in getter accessors, and just re-read the Memory Management Programming Guide (MMPG) to understand this. Now I do, and see how the perhaps once canonical approach of having a setter release-then-retain (if the new value is not equal to the present value) can lead to references persisting to a released object (e.g., if the setter is invoked after the getter has issued references). In fact, the MMPG goes so far as to say this about this approach:

"...because of the potential dangers of invalidating objects prematurely, use of this technique should be used sparingly and well documented."

So, I am curious as to why the default (retain) behavior of @synthesize does just this?

And, is there a way to tell @synthesize to use one of the other approaches, or do I need to make such a property @dynamic and handle the setter/getter myself?


Note that you don't have to declare the property dynamic to override the getter or the setter. The compiler is smart enough to synthesize only the missing methods.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Memory Management and @synthesized accessors (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: RegisterEventHotKey still the best way for global hotkeys
  • Next by Date: Re: Window Animation with setFrame:display:animate: Flickers
  • Previous by thread: Re: Memory Management and @synthesized accessors
  • Next by thread: NSNotificationCenter : multiple messages sent to the same observer?
  • Index(es):
    • Date
    • Thread