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: Kyle Sluder <email@hidden>
- Date: Fri, 01 Aug 2014 10:51:26 -0700
On Aug 1, 2014, at 10:33 AM, Sean McBride <email@hidden> wrote:
>
> On Thu, 31 Jul 2014 09:26:27 -0700, Jerry Krinock said:
>
>>> One thing I just noticed is that NSWindowController's 'document'
>> property is not actually documented as KVO-compliant. Maybe that's my
>> problem... but I've been binding through it for over a decade now!
>>
>> That may well be the real problem, Sean.
>
> Yup! Seems like it is.
>
>> In a similar situation, I solved the “bindings burp” (what I call that
>> nasty message you copied from the console) by inserting *another* object
>> controller into the bindings “path”, to control the *document*.
>
> I've tried some similar permutations and they have 'fixed' the issue. I have about 50 xibs to fix now, so want to be sure I do this correctly. :) I now find myself questioning basic things. :)
>
> NSWindowController's 'document' property is not documented as KVO-compliant, and neither is NSPersistentDocument's 'managedObjectContext' property.
>
> Which parts of a binding's keypath have to be KVO-compliant? If all parts, how can 'document' and 'managedObjectContext' even be in there at all? Even in interstitial object controllers as you described?
Because of the NSDocument lifecycle, you can presume these properties will not change while the window is being shown.
You could manually unbind the object controller in -windowDidClose: or in an override of -setDocument:, and any other controllers bound through it will hear about the change in a KVO-compliant way.
--Kyle Sluder
_______________________________________________
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