Re: customizing save behavior in doc based apps
Re: customizing save behavior in doc based apps
- Subject: Re: customizing save behavior in doc based apps
- From: email@hidden
- Date: Mon, 26 Dec 2005 16:59:43 -0500
On Dec 26, 2005, at 4:33 PM, Uli Kusterer wrote:
Am 26.12.2005 um 22:08 schrieb Jim Correia:
If you really want to save after every set of changes, listen to
the notifications designed for that purpose. An override of -
updateChangeCount: or listening for
NSManagedObjectContextObjectsDidChangeNotification both seem like
more appropriate solutions.
In addition to that, you may want to not save on every change. You
could do that by setting up one-shot a timer that will trigger a
save in 3 seconds, then remove itself. Whenever a new change
happens and the timer is still pending (i.e. has been installed but
hasn't yet fired) you simply reschedule it to fire, say, 3 seconds
from *that* point in time. That way, while the user is busy
changing stuff, the timer will silently be pushed back. As soon as
the user makes a short pause (i.e. doesn't do anything for three
seconds) the changes will be written to disk.
Great point. I definitely don't want the disk churning away with
every single input and this seems like an elegant way to avoid that.
Really, all I want is for changes to automatically get saved to disk
whenever the user closes the window or quits the app. The only time I
want them to get prompted for a save is when they try to close the
window or quit the app with an untitled document -- which is why I
was originally trying to override close and applicationShouldTerminate:
For the sake of my own learning, can we really say that overriding
updateChangeCount: or listening for the change count and using the
timer together is a better solution than overriding close and
applicationShouldTerminate: and handling the saves there -- for the
purposes of giving a "continuously saved" appearance? From mmalc's
initial response, it appeared that saving the context every time an
edit occurred would be less complicated than what I was originally
doing, but now I'm starting to wonder? In any event, I'd be
interested in knowing what you all think about the merits of my
initial approach just for the sake of improving my style if that's
what this all boils down to at this point.
And BTW Jim, great point about questioning why I'm fighting the
document architecture style so much in the first place. I'm
definitely mulling over that thought because it really is starting to
seem like this might be a little too out of the way for a doc based
app (and I bet mmalc would agree, per his initial comment).
M.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden