Core Data managed object context thread synchronisation

前端 未结 1 1727
借酒劲吻你
借酒劲吻你 2021-02-06 07:38

I\'m have an issue where i\'m updating a many-to-many relationship in a background thread, which works fine in that threa, but when I send the object back to the main thread the

1条回答
  •  不思量自难忘°
    2021-02-06 08:17

    If you save the background context on the background thread and then listen for NSManagedObjectContextObjectsDidChangeNotification on the main thread you can call -mergeChangesFromContextDidSaveNotification: on the main context (on the main thread) and the changes will show up as soon as you perform the save on the background thread.

    0 讨论(0)
提交回复
热议问题