cocoa - Core Data and threading -
What are some ambiguous losses to using core data and threads? I have read a lot of documents, and so far I have come in the following through docs or painful experience:
- Use a new NSManagedObjectContext for each thread, but a single NSPersistentStoreCoordinator is a whole app Is enough for
- Before sending the object of the NSMANAd object back to the main thread (or any other thread), make sure the reference is saved (or at least, it was not new - just-on-now-saved No object) - otherwise objectID would actually be a temporary ID and not a constant one.
- Use merge changframontaxdeswen notification: When a saved one is in another thread and it is used to merge those changes with reference to the current thread.
Bonus Question / Observation: I was believed by the words of some documents that merge changframontaxidens notification: only necessary by the main thread to merge the change in the "main" reference from the worker thread But for the sake of I did not - that's the case.
I establish my importer for batch of data that is imported using a sub-class of NSOperation which is its own reference operation is loaded in an NSOperationQueue Which is set to allow the default number of concurrent tasks, it is possible that many import batches should run at the same time. I will sometimes get very strange verification errors and exceptions (such as trying to add a relation to a relationship) and other failures that I have never seen when I did all the stuff on the main thread. It happened to me (and perhaps it should be clear) that perhaps every scholar should merge the necessary references for all references - not just "main"! I do not know why I did not think before that, but I thinks it helps (it has not been tested enough yet, although for me to make sure it still Not enough.) In any case, is it true that you have to follow the information for all import threads working with the same datasets and adding / updating the same institutions? If so, this is another bad bullet point IMO, although I still have to make sure that it will work.
Given that how many of these have I run with core data in general (and not all about multi-threading), I would be surprised how many more are secret since multi-threading is often Ends with a time which is difficult if it is not impossible to reproduce due to time issues, then I think that if there are other important things that I am missing, then I would have worried with you. Is required. / P>
This is a complete document dedicated on this topic.
This is not clear from the set of issues that are not covered by that document.
Comments
Post a Comment