Re: @property and Garbage Collection
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