With Auto Save enabled in a document, I find that Lion sometimes wants to break 
into a sequence of operations to do an Auto Save.  I haven't been able to find 
any recommendation of how to tell Auto Save "No, I'm busy now".  I just figured 
out how to do it by overriding saveToURL::::.

It seems to work.  I'd appreciate any criticisms:

- (void)saveToURL:(NSURL *)url
           ofType:(NSString *)typeName
 forSaveOperation:(NSSaveOperationType)saveOperation
completionHandler:(void (^)(NSError *errorOrNil))completionHandler {
    if (saveOperation == NSAutosaveInPlaceOperation) {
        if ([[[NSOperationQueue mainQueue] operations] count] != 0) {
            // "No, I'm busy now"

            // If you don't do this, it hangs forever…
            completionHandler(nil) ;

            return ;
        }
    }
    
    // Optional…
    [self prepareForSaveOperation:saveOperation] ;
    
    [super saveToURL:url
              ofType:typeName
    forSaveOperation:saveOperation
   completionHandler:completionHandler] ;
}

_______________________________________________

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

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

Reply via email to