Re: Temporarily disabling autosave
Re: Temporarily disabling autosave
- Subject: Re: Temporarily disabling autosave
- From: Mike Abdullah <email@hidden>
- Date: Wed, 24 Apr 2013 11:10:34 +0100
On 24 Apr 2013, at 04:16, Steve Mills <email@hidden> wrote:
> On Apr 23, 2013, at 17:39:17, Mike Abdullah <email@hidden>
> wrote:
>
>> -hasUnautosavedChanges continues to be applicable to all (auto)saving models.
>>
>> I caution against overriding it since:
>>
>> A) Your override is likely a lie to the system when you get down to it. This might upset the state for other bits of the system
>> B) A perfectly good system for backing out of non-essential autosaves already exists, and should be used instead
>
> Then why would hasUnautosavedChanges be exposed publicly with no documentation that says overriding it is a bad idea?
To be fair, there's plenty of methods in the frameworks that are public and a bad idea to override, but not explicitly documented as such. The team may not have considered that anyone might actually want to override it. Or they simply forget. Or maybe I'm wrong and it's perfectly reasonable to override.
>
>> If you read the docs for -autosaveWithImplicitCancellability:completionHandler: *its* implementation calls -hasUnautosavedChanges. It will back out without doing any work should the document claim not to have any unautosaved changes.
>
> Yes, but if hasUnautosavedChanges returns NO, then autosaveWithImplicitCancellability won't autosave. I don't see what difference it makes which one I override, except hasUnautosavedChanges is a much simpler method to understand and override.
I'm just pointing out that your override comes down to lying about the document's state (claiming a doc is autosaved when it isn't really), and that that would make me uncomfortable in my code.
>
>> I suspect that if you do override -hasUnautosavedChanges, a call to -scheduleAutosaving would be needed — at least under some circumstances — to restart autosave when you’re ready.
>
>
> Not from my tests. If I cause an autosave to happen before I pause it locally, then later when it's resumed, any dirtying of the document is all that is needed to cause an autosave to fire again when the autosave time interval has elapsed.
OK, that's good. Not that it's guaranteed to be the case for future OS's mind…
_______________________________________________
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