• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: -[NSDocument fileURL] is observable (KVO). Documented?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSDocument fileURL] is observable (KVO). Documented?


  • Subject: Re: -[NSDocument fileURL] is observable (KVO). Documented?
  • From: Kyle Sluder <email@hidden>
  • Date: Tue, 1 Jun 2010 14:35:32 -0700

To clarify: Mike is of course correct that any class that doesn't have
an override of +automaticallyNotifiesObserversForKey: which returns no
for a given key, and that always sets values of that key in a
KVC-compliant manner, will generate KVO notifications for that key.
And there are many Cocoa classes that have not bothered to override
+automaticallyNotifiesObservesrForKey:. But one should *not* develop
the expectation that most, or even a substantial portion, of Cocoa is
KVO-compliant, because it is not.

--Kyle Sluder

On Tue, Jun 1, 2010 at 2:15 PM, Mike Abdullah <email@hidden> 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

  • Follow-Ups:
    • Re: -[NSDocument fileURL] is observable (KVO). Documented?
      • From: Mike Abdullah <email@hidden>
References: 
 >-[NSDocument fileURL] is observable (KVO). Documented? (From: Jerry Krinock <email@hidden>)
 >Re: -[NSDocument fileURL] is observable (KVO). Documented? (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: -[NSDocument fileURL] is observable (KVO). Documented?
  • Next by Date: Re: Which color space?
  • Previous by thread: Re: -[NSDocument fileURL] is observable (KVO). Documented?
  • Next by thread: Re: -[NSDocument fileURL] is observable (KVO). Documented?
  • Index(es):
    • Date
    • Thread