objective c - Sharing Non-Persistent Objects Between Contexts in Core Data? -


i wondering if there way share nsmanagedobject between 2 or more nsmanagedobjectcontext objects running in same thread.

i have following problem: have 1 main context shared through code in application , several different contexts created each remote fetch request issue. (i created custom class fetches remotely , inserts objects found in server in own nsmanagedobjectcontext). fetch requests may run simultaneously since use nsurlconnection objects may end @ different times. if same remote object gets fetched different connections, end duplicates @ moment of saving , merging context main one. (that is, objects have same remote id different objectid).

one possible solution save (and persist) every object created can't because may have relationships may still have not been filled , won't validate during save operation.

i'm looking forward method allows share same non-persistent instance of object between context. if has encountered issue , came solution, pleased know!

context cannot communicate between each other save through stores. however, can insert managed object nil managed object context , independent (albeit without relationships) of context. pass independent managed object around wished , insert context when needed persist it. dangerous possible.

however, if you're not running each connection on separate thread don't gain having multiple context. each connection object activate delegate in sequence on main thread. in case, easiest solution use same delegate connections , let delegate handle insertions single context. prevent duplication, fetch on remoteid , see if extant object before inserting new object remoteid.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -