Is NSPersistentStoreCoordinator Thread Safe?

前端 未结 2 558
攒了一身酷
攒了一身酷 2021-02-05 23:04

I\'m working on an iPhone app that uses Core Data. The app makes a call to a web service, parses the resulting XML file, and then creates or modifies Core Data objects in my app

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 23:35

    Is it possible to have a second managed object context running on a separate thread sharing the same NSPersistentStoreCoordinator with the main thread?

    Yes! I recommend you to read the corresponding section of Zarra's book carefully before venturing into multi-threaded access to CoreData.

    Or, more succinctly, is NSPersistentStoreCoordinator thread-safe?

    Well, the word `thread-safe' has shades of meaning in the Apple doc, so be very careful! See this blog article for a nice explanation.

提交回复
热议问题