Re: NSCopyObject is a disaster (was Re: Another NSOutlineView issue)
Re: NSCopyObject is a disaster (was Re: Another NSOutlineView issue)
- Subject: Re: NSCopyObject is a disaster (was Re: Another NSOutlineView issue)
- From: Greg Parker <email@hidden>
- Date: Mon, 13 Aug 2012 14:41:47 -0700
On Aug 13, 2012, at 2:12 PM, Uli Kusterer <email@hidden> wrote:
> On 09.08.2012, at 01:21, Graham Cox <email@hidden> wrote:
>> If a superclass implements copies using NSCopyObject, then any pointer ivars we add in a subclass need to be additionally -retained. But if the superclass implements copy by alloc/initing a new object and setting properties, then this extra step would lead to an over-retain and so leak.
>
> Not really. It *must* correctly do the additional retains for the ivars it created, but yours are just copied as integers to the new object. So you could simply rely on that if you know your base class uses NSCopyObject(). Alternately (and more safely) you can just ignore the value in there (as you know it either hasn't been retained, or is NIL altogether)
You don't know that. If the superclass called alloc/init, and your subclass init sets that ivar to a retained value, then the copy's ivar is retained and not nil.
--
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