I have a singleton class and I want to access it from multiple threads. The class return data from core data. I have two nsmanagedobjectcontext for each thread. Should I pass the nsmanagedobjectcontext to the singleton class from each thread?
preguntado el 27 de agosto de 11 a las 14:08
It's safe to access Core Data from different managed object contexts in different threads. You should pass the managed object context to your singleton somehow. Whether your own code in your singleton class is thread safe is up to you.
Another option would be to use one managed object context for all the threads, but lock the persistent store before accessing any Core Data properties. Multiple managed object contexts is preferable, though.