Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 948
Baub Avatar asked Feb 23 '23 11:02

Baub


1 Answers

[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! :)

like image 172
XJones Avatar answered Mar 04 '23 12:03

XJones