Undo core data managed object

后端 未结 5 2127
野性不改
野性不改 2021-02-06 15:26

I have this code:

Store* store = [NSEntityDescription insertNewObjectForEntityForName:@\"Store\"];
store.name = @\"My Company\"
...

Now the sto

5条回答
  •  星月不相逢
    2021-02-06 15:57

    Core Data has built-in support for undo, so you can undo individual changes by sending the -undo message to the context:

    [store.managedObjectContext undo];
    

    It also supports -redo. You can undo all changes up to the most recent save using the -rollback method:

    [store.managedObjectContext rollback]
    

    as indicated in @melsam's answer.

提交回复
热议问题