• 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
NSDocument and KVO compliance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument and KVO compliance


  • Subject: NSDocument and KVO compliance
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 18 Oct 2013 19:41:06 +0100

Twice recently I have found myself tinkering with NSDocument et al to support observing of certain values.
For example, NSDocument -isDocumentEdited is not seemingly KVO compliant.
-isDocumentEdited status is driven by -updateChangeCount: so

in MYDocument : NSDocument the override is::

- (void)updateChangeCount:(NSDocumentChangeType)change
{
    [self willChangeValueForKey:@"isDocumentEdited"];
    [super updateChangeCount:change];
    [self didChangeValueForKey:@"isDocumentEdited"];
}

Similarly for NSDocumentController and -recentDocumentURLs

in MYDocumentController : NSDocumentController the override is:

- (void)noteNewRecentDocumentURL:(NSURL *)aURL
{
    [self willChangeValueForKey:@"recentDocumentURLs"];
    [super noteNewRecentDocumentURL:aURL];
    [self didChangeValueForKey:@"recentDocumentURLs"];
}

Is this the best way to go about addressing these sorts of issues with regard to missing KVO compliance?

Jonathan












_______________________________________________

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 and KVO compliance
      • From: Seth Willits <email@hidden>
  • Prev by Date: Re: C functions
  • Next by Date: Re: NSDocument and KVO compliance
  • Previous by thread: Re: C functions
  • Next by thread: Re: NSDocument and KVO compliance
  • Index(es):
    • Date
    • Thread