Re: -[NSDocument fileURL] is observable (KVO). Documented?
Re: -[NSDocument fileURL] is observable (KVO). Documented?
- Subject: Re: -[NSDocument fileURL] is observable (KVO). Documented?
- From: Scott Anguish <email@hidden>
- Date: Tue, 1 Jun 2010 23:44:14 -0400
Kyle gave the long answer.
But, if it isn’t documented, don’t count on it (although there is some backfill required there).
Also, being KVO compliant doesn’t necessarily mean you can simply bind to it, as you can’t be sure that the result will be returned on the main thread.
KVO compliance documentation is in place where it is known (typically in new classes) and will be updated in older classes as possible/info is available.
On Jun 1, 2010, at 5:15 PM, Mike Abdullah wrote:
> By default Cocoa classes use automatic KVO. So long as Cocoa always changes the URL by calling -setFileURL: you will get proper notifications.
>
> On 1 Jun 2010, at 22:02, Jerry Krinock wrote:
>
>> There is no mention in -[NSDocument fileURL] documentation, nor in 10.5 or 10.6 release notes, that this property is observable using KVO. But when I added some code to do this, created a document, and renamed the document in Finder while the document was open, my observer logged a hit.
>>
>> Is there some underlying or other documentation I don't know about?
>>
>> Jerry Krinock
>>
>>
>> - (void)observeValueForKeyPath:(NSString*)keyPath
>> ofObject:(id)object
>> change:(NSDictionary*)change
>> context:(void*)context {
>> NSLog(@"2796: keyPath %@ observed:\n%@", keyPath, change) ;
>> }
>>
>> - (id)init {
>> self = [super init] ;
>> if (self != nil) {
>> [self addObserver:self
>> forKeyPath:@"fileURL"
>> options:NSKeyValueObservingOptionNew
>> context:NULL] ;
>> }
>>
>> return self ;
>> }
>>
>> - (void)dealloc {
>> [self removeObserver:self
>> forKeyPath:@"fileURL"] ;
>>
>> ...;
>> [super dealloc];
>> }
>>
>>
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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
_______________________________________________
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