Re: ARC and NSObjectController bindings through file's owner
Re: ARC and NSObjectController bindings through file's owner
- Subject: Re: ARC and NSObjectController bindings through file's owner
- From: Ken Thomases <email@hidden>
- Date: Wed, 30 Jul 2014 15:45:04 -0500
On Jul 30, 2014, at 3:33 PM, Sean McBride <email@hidden> wrote:
> I'm slowing moving my GC app to ARC. One runtime error I'm stuck at is:
>
> --------
> An instance 0x10f587510 of class MyDocument was deallocated while key value observers were still registered with it.
>
> <NSKeyValueObservance 0x107985ad0: Observer: 0x107985810, Key path: document.managedObjectContext, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x10ee1ac10>
> --------
>
> I have:
> - a nib who's File's Owner is an NSViewController subclass
> - an NSObjectController at the top-level of my nib
> - a strong IOOutlet from my NSViewController to the NSObjectController
> - the NSObjectController binds its 'managedObjectContext' binding to:
> File's Owner.windowController.document.managedObjectContext
>
> It's something about that binding that's causing the trouble. If I remove it, the error goes away.
>
> File's Owner (my NSViewController subclass) responds to 'windowController' because I have a vanilla synthesized weak property relating my NSViewController to its containing window's controller.
>
> It works under GC. I just don't see how this is a problem under ARC... any one have any thoughts?
A zeroing weak property changes without emitting KVO change notifications. Therefore, it's not KVO-compliant. Basically, weak properties are incompatible with KVO and bindings.
Likewise, if any other property along that key path is changed in a non-KVO-compliant manner, that would lead to the same sort of error.
Regards,
Ken
_______________________________________________
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