re: Autosaving in an NSPersistentDocument
re: Autosaving in an NSPersistentDocument
- Subject: re: Autosaving in an NSPersistentDocument
- From: Ben Trumbull <email@hidden>
- Date: Sun, 20 Jul 2008 00:44:23 -0700
Rick,
There's a difference in NSDocument parlance between "save", "save as",
"save to", and "auto save". None of those things are "saves
automatically, after a timer or notification"
You can easily implement "saves automatically". Apps like iCal simply
save at the end of the event, piggy back off the
NSManagedObjectContextObjectsDidChangeNotification.
Core Data has always supported Save As... style functionality, and
whether you trigger a -save: invocation by a menu action, binding,
timer, or notification doesn't matter.
The difference between "auto-save" and "automatically saves" is
whether or not the current document is clean or dirty afterwards. An
NSDocument auto-save creates a new backup document file, but does not
in any way disturb the current edits that the user may be working
with. Automatically saving is just flushing the current edits to disk
to the main document file.
The NSManagedObjectContext simply doesn't have a way to save, but
pretend like all those changes are still pending.
You could fake it by migrating the store to the backup location,
creating a second context, pulling all the deltas from the original,
save, and then tossing the second context.
- Ben
_______________________________________________
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