Baub
Baub

Reputation: 5044

Core Data Save Changes Undo

I am using CoreData in my applcation that takes coordinates and saves them (along with other data) into the persistent store.

The application flow is like this: User pushes a button, coordinates are added every time the user moves and they are placed into the managedObjectContext. The user presses another button and the application stops putting coordinates into the managedObjectContext and asks the user if they want to save their data. If the user wants to save their data, I call [managedObjectContext save:&error]; and check for the error. If the user does not want to save, the coordinates just sit in the managedObjectContext until the application is completely closed and reopened.

How can I remove those points that the user does not want to save?

Upvotes: 4

Views: 1730

Answers (1)

XJones
XJones

Reputation: 21967

[managedObjectContext rollback] will discard any changes made to the context since the last save. If you want finer grain control add an NSUndoManager to the context and break out the docs! :)

Upvotes: 8

Related Questions