Undoing Core Data insertions that are performed off the main thread

前端 未结 5 2020
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 09:41

I\'m working on some code that uses an NSOperation to import data. I\'d like for the user to be able to undo the NSManagedObject instances that are cre

5条回答
  •  一向
    一向 (楼主)
    2021-01-30 10:11

    Not an expert, but I think what you're going to need to do is create a second context to perform the operations, then merge the two contexts together. You should be able to manage the merge as an undo step. Note, this only works if you're treating the entire set of operations as one undo step, as far as the user is concerned.

提交回复
热议问题