On 2014 Jun 19, at 22:15, John Brownie <john_brow...@sil.org> wrote:

> Looks like I need to keep a local flag for when the document gets changed and 
> when it gets saved.

No, you can just use -[NSDocument isDocumentEdited].

Back when Auto Save first appeared, in OS X 10.7, I too found that it was 
pestering me too often with autosaves when nothing had changed.  Fortunately, 
such nuisance autosaves seem to always be cancelable, so it’s easy to fix by 
overriding -autosaveWithImplicitCancellability:completionHandler:, like this…

- 
(void)autosaveWithImplicitCancellability:(BOOL)autosavingIsImplicitlyCancellable
                         completionHandler:(void (^)(NSError 
*errorOrNil))completionHandler {
    if (autosavingIsImplicitlyCancellable) {
        if (![self isDocumentEdited]) {
            // Cancel it.
            completionHandler([NSError errorWithDomain:NSCocoaErrorDomain
                                                  code:NSUserCancelledError
                                              userInfo:nil]) ;
            return ;
        }
    }
    
    … Here, I add a save operation to my document's operation queue.
    … If you don't save that way, probably just invoke super here.
}



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to