• 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: @property and Garbage Collection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @property and Garbage Collection


  • Subject: Re: @property and Garbage Collection
  • From: James Bucanek <email@hidden>
  • Date: Tue, 25 Jan 2011 08:46:10 -0700

Kevin Bracey <mailto:email@hidden> wrote (Tuesday, January 25, 2011 2:59 AM +1300):

In a Garbage Collected App when using the @property is it correct that I still
have to specify (copy) or (retain) or have I missed something? I thought using
GC didn't require retain and that everything could just be assigned, but the
complier complains.

You're correct; GC doesn't require retain, and retain in a GC environment is a no-op.


In general, however, I'd suggest ignoring whether the environment is GC or not. Specify assign, copy, or retain based on the usage pattern of the property. That way, if you find yourself in a non-GC environment, it will still work.

While I write my properties this way, I may omit the retain/release messages in my code if I'm _sure_ it will never see a non-GC environment. But even when I'm writing a GC application, if the classes have utility beyond this application, and there's a reasonable chance that I'd like to use them in a non-GC environment, I'll write full retain/release code so that's functional in both.

--
James Bucanek

_______________________________________________

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: 
 >@property and Garbage Collection (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: Loading the Foundation at runtime
  • Next by Date: Re: [iPhone] can't get views not to slide off by the height of the status bar
  • Previous by thread: Re: @property and Garbage Collection
  • Next by thread: How send XML data to document window?
  • Index(es):
    • Date
    • Thread