• 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: Greg Parker <email@hidden>
  • Date: Tue, 25 Jan 2011 12:09:54 -0800

On Jan 25, 2011, at 2:15 AM, Kevin Bracey wrote:
> Yes, I can see the the rule for copy, I'm guessing it still makes a copy.
>
> I'm a little confused as to what ( retain ) now does, does it now also do a copy, If I remove the ( copy ) I get
> warning: default 'assign' attribute on property 'allImportHeaders' which implements 'NSCopying' protocol not appropriate with -fobjc-gc-only

(retain) and (assign) are identical under GC. (copy) still calls the -copy method.


> so I'm unsure should I use the retain or copy keyword for the objects that conform to the 'NSCopying' protocol?


That depends on how your code should behave. Sometimes you want (assign) and sometimes you want (copy), even though GC is on.

When the compiler sees a class that conforms to NSCopying, it requires you to explicitly write what you want instead of giving you (assign) by default. The hope is that the extra prompt to think about your code and maybe avoid a bug is worth the extra keystrokes.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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

  • Prev by Date: Re: Weather API for commercial use in iOS app
  • Next by Date: Re: lots of find/replace in text file
  • Previous by thread: Re: @property and Garbage Collection
  • Next by thread: Re: @property and Garbage Collection
  • Index(es):
    • Date
    • Thread