I have a View Controller that manages a view which is always shown in editing mode. The view is essentially a table view similar to that of a contact's details in Apple's Contacts app. The model underneath my view is represented by a 2-level object graph comprised of a root entity - call it R
- having a to-many relationship to a child entity C
. Now, R
is a large object (it has 20+ attributes, all editable but non-mandatory). By default, R
has n
children (n
being a configurable value), but child objects can be added and removed to/from R
's collection via my editing view and C
's attributes can be edited as well. Note that C
entities include attributes for image meta-data, so there may be images picked and associated with the model while editing.
Edits on R
and its children are performed via the main table view form, as well as from "secondary" views to which I navigate (back and forth) in order to collect the required information, depending on the case.
My question is, how would you implement a "Cancel all edits" in this situation, i.e. how should I isolate all my edits to easily revert to the state prior to editing? Using a NSUndoManager
with my main NSManagedObjectContext
? Having a separate NSManagedObjectContext
for editing? What would be the trade-offs for each?
I don't care for redo
. I am looking for an idea/solution that would strike a balance between the amount of memory used while editing vs. the ability to save the user's data if the app is interrupted while editing.
Thank you for all your ideas.