开发者

Getting Notifications of isDocumentEdited

is it possible to bind/get notifications of the isDocumentEdited property of NSDocument witho开发者_C百科ut calling the will/didChangeValueForKey: methods on every change?


Override -updateChangeCount: in your subclass so it posts an NSNotification or does whatever work you're after.


I'll extend Mike Abdullah's answer:

To get bindings to work with isDocumentEdited, I implemented the following override on the NSDocument method:

- (void)updateChangeCount:(NSDocumentChangeType)change
{
    [self willChangeValueForKey:@"isDocumentEdited"];
    [super updateChangeCount:change];
    [self didChangeValueForKey:@"isDocumentEdited"];
}
- (void)updateChangeCountWithToken:(id)changeCountToken forSaveOperation:(NSSaveOperationType)saveOperation
{
    [self willChangeValueForKey:@"isDocumentEdited"];
    [super updateChangeCountWithToken:changeCountToken forSaveOperation:saveOperation];
    [self didChangeValueForKey:@"isDocumentEdited"];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜