Re: Telling Auto Save, "No, I'm busy now"
Re: Telling Auto Save, "No, I'm busy now"
- Subject: Re: Telling Auto Save, "No, I'm busy now"
- From: Jerry Krinock <email@hidden>
- Date: Sat, 30 Jul 2011 18:41:12 -0700
On 2011 Jul 30, at 15:39, email@hidden wrote:
> You're lying to the save machinery by saying that you have saved, when you have not. So NSFileCoordinator will then think your file is up to date, and let others read (or write) it. It could lead to all sorts of nasty behaviors…
Thank you, Wade. Yes, that's a good point.
> What you should be doing is deferring the save - just hang on to 'completionHandler', queue up the save for the next available opportunity, and invoke the handler after the save really happens.
OK, but I thought of an easier solution. Replace this line of code
completionHandler(nil) ;
which told the system that I had saved with no error, with this:
completionHandler([NSError errorWithDomain:NSCocoaErrorDomain
code:NSUserCancelledError
userInfo:nil]) ;
Now I'm not lying to Mother any more. And because this particular error domain/code is documented to not be displayed (see -Document-Based Applications Overview â–¸ Error Handling in the Document Architecture), the user doesn't get any crap.
Indeed, the behavior is a little different now. Instead of waiting 10-15 seconds after my operations are completed, now the Auto Save happens immediately after my operations are completed. This implies that the system now knows that it has unsaved data, and so it kicks in more aggressively.
I like it better now. But it still seems that Apple should document the correct way to handle this situation.
> you're in the middle of applying a user action, one that has been expressly approved and is merely taking some time
Yes, that is the situation.
_______________________________________________
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