Re: ARC dealloc best pratice
Re: ARC dealloc best pratice
- Subject: Re: ARC dealloc best pratice
- From: Jonathan Mitchell <email@hidden>
- Date: Fri, 06 Feb 2015 21:41:04 +0000
> On 6 Feb 2015, at 17:34, Jens Alfke <email@hidden> wrote:
>
>
>> On Feb 6, 2015, at 6:48 AM, Jonathan Mitchell <email@hidden> wrote:
>>
>> // remove observers
>> // unregister for notifications
>
> I have to confess I'm still not completely certain whether these are needed under ARC. I remember reading something about at least one of these being handled automatically, but I just skimmed through some docs now and couldn't find anything. I tend to put these in my classes but always wonder whether I strictly need to.
I was just checking whether I needed to manually unbind any bindings that I make manually.
Looks like I don’t, according to the fragment below from the NSKeyValueBinding.header.
Binding obviously involves observation and the header note makes it explicit that removing observers is recommended.
I think the one exception is self observation.
I think under GC observers may have been removed automatically - cannot quite recall.
Header note:
Bindings are considered to be a property of the object which is bound (the object the following two methods are sent to) and all information related to bindings should be retained by the object; all standard bindings on AppKit objects (views, cells, table columns, controllers) unbind their bindings automatically when they are released, but if you create key-value bindings for other kind of objects, you need to make sure that you remove those bindings when you release them (observed objects don't retain their observers, so controllers/model objects might continue referencing and messaging the objects that was bound to them).
Jonathan
_______________________________________________
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