NSDocument and KVO compliance
NSDocument and KVO compliance
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