Re: Strange issue with NSPanel @"visible" keypath & observeValueForKeyPath
Re: Strange issue with NSPanel @"visible" keypath & observeValueForKeyPath
- Subject: Re: Strange issue with NSPanel @"visible" keypath & observeValueForKeyPath
- From: vade <email@hidden>
- Date: Sat, 10 Sep 2011 11:23:49 -0400
Indeed you are correct, I confused the fact that because the binding is available, that KVO would be available on the same key, which is not strictly true or required.
I decided to use binding instead, and while that seemed like it should have worked, it did not on 10.6.8, so I just ended up sub-classing and it met my goal. Thank you.
On Sep 7, 2011, at 10:50 PM, Chris Hanson wrote:
> On Sep 7, 2011, at 5:58 PM, vade wrote:
>
>> I have an NSWindow, which my app controller is observing the value of @"visible" keypath, with the following line
>>
>> [previewWindow addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionNew context:NULL];
>>
>
> How did you determine that was a valid key path to observe? (That is, that the property at the end of the key path - and all intermediate keys - supports KVO?)
>
> In general you can't rely on any arbitrary property, especially of a user interface component like an NSWindow or NSView, supporting KVO.
>
> Instead you should use the notifications the component makes available explicitly for notifying observers of interesting happenings.
>
> -- Chris
>
_______________________________________________
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