Undoing Core Data insertions that are performed off the main thread

前端 未结 5 2060
爱一瞬间的悲伤
爱一瞬间的悲伤 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:29

    Suppose that you use a separate context for the background thread, and once it's done, push a [[backgroundContext undoManager] undo] onto the foreground thread's undo stack? I've never tried anything like that, but off the top of my head I can't think of a reason it shouldn't work.

提交回复
热议问题