Undoing Core Data insertions that are performed off the main thread

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

    One option may be to make your import thread persistent. Even when the thread is finished importing, it goes into an idle loop state. This way your threaded ManagedObjectContext is persisted in the proper thread. Then when the user wishes to undo a change, send a message to the thread to use the undomanager.

提交回复
热议问题