ios - Can you use an NSManagedObject outside of it's context's performBlock? -
nsmanagedobjectcontext's have had performblock: , performblockandwait: methods added make concurrency easier. i've been using them -- potentially naively -- , realized there's question i've never asked.
if create nsmanagedobject subclass inside 1 of performblock methods, it's 'home' thread thread of it's parent context -- in case of nsprivatequeueconcurrencytype independent thread have no other access to.
so need performblock call access data contained inside managed objects? or there background magic going on protect me in case of using getters? (or setters, though seems bad idea...)
nsmanagedobject
not supposed used outside of managedobjectcontext
s thread/queue (sometime works , times crash ==> don't it).
coredata not guarantee safe read access object.
to access object owned "private queue" context, use either [context performblock:...]
or [context performblockandwait:...]
, unless access objectid
or managedobjectcontext
properties.
Comments
Post a Comment