Re: bindings via file's owner don't update
Re: bindings via file's owner don't update
- Subject: Re: bindings via file's owner don't update
- From: Mikkel Eide Eriksen <email@hidden>
- Date: Tue, 30 Nov 2010 18:39:31 +0100
On Nov 30, 2010, at 5:34 PM, Quincey Morris wrote:
> On Nov 29, 2010, at 21:36, Mikkel Eide Eriksen wrote:
>
>> I'm updating the objectCount property during readFromURL:ofType:error: - could that be it?
>
> No, that's a suitable method, but the question is whether it's running in the main thread or if the document initialization process got switched to a background thread for some reason. (That would only happen if you wrote code to make it happen.)
>
> Previously, you logged 'addObserver:...' to establish that the observer of document.objectCount got registered. You could also trying to see whether "objectCount" notifications are being issued at all. Have some object (e.g. the loading window controller itself) manually observe the property and see whether the observer gets told when the property changes.
I just implemented - (void)observeValueForKeyPath:ofObject:change:context: on my LoadingWindowController and registering as an observer of MyDocument.objectCount. I do indeed get notifications if I do it this way.
> Another possibility is that you've (somehow) caused two document objects to be created. That sort of thing can happen when you [also] instantiate an object in a nib file that's normally created in code. Or it could be 2 window controllers, or 2 windows.
I also added some symbolic breakpoints to the -init methods of MyDocument & MyLoadingWindowController but only one of each are created so it doesn't appear there's a rogue object there.
What about the Options: <New: NO, Old: NO, Prior: NO> below? As I read it, it seems that MyLoadingWindowController registers the NSTextField of its nib as an observer, but the text field doesn't want any values (ie no notifications)? Or does that just mean that the the text field will call back to MyDocument and grab the property for itself when/if it receives a notification?
2010-11-30 18:26:12.192 MyCoreData[57991:a0f] MyLoadingWindowController addObserver:<NSTextValueBinder: 0x20026d680>{object: <NSTextField: 0x200284240>, bindings: value=document.objectCount} forKeyPath:"document.objectCount" options:context:
2010-11-30 18:26:12.192 MyCoreData[57991:a0f] MyDocument addObserver:<NSKeyValueObservance 0x200256780: Observer: 0x20026d680, Key path: document.objectCount, Options: <New: NO, Old: NO, Prior: NO> Context: 0x20025ba80, Property: 0x2000f3ba0> forKeyPath:"objectCount" options:context:
Mikkel
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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