¿Es seguro el hilo único para los datos principales?

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

1 Respuestas

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.

Respondido 27 ago 11, 19:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.