bits about life, coding and stuff
Multithreading is always tricky. Here are some gotchas i had when working with core data, multithreaded.
- be sure to check out apples documentation on it. but well, thats not enough…
- Always generate a NEW CONTEXT for a thread. no sharing!
- set a MERGE POLICY for all contexts. Core Data uses optimistic locking, and by default simply rejects everything that was changed concurrently (even if there were different parts of the class changed)
Well, sometimes automatic merging is not enough. Then its going to be tricky – you have to react on the NSError from the save of the context. And there can be A LOT information it it. Check out this blog post for an in-deph report.
Maybe I’ll put some more information there while my app is progressing…
Related posts: