iphone - Core Data: Illegal attempt to establish relationship + (null) context -


i parsing data on background thread, inserting new entities , setting relationships other existing entities.

sometimes error: 'attempting establish relationship between objects in different contexts'.

after reading more creating new managedobjectcontect in background thread , using insert new entities , setup relationships. careful use new managedobjectcontext in background thread. when need find existing entity setup relationship between existing object , 1 of these new objects, call [moc objectwithid:id] fetch existing object using new moc. however, still getting error.

frustrated, started printing things out. noticed when print out managedobjectcontext property each nsmanagedobject, before setting relationship, '(null)' printed out. seems when problem occurs.

can tell me doing wrong? why have (null) mocs on objects?

thanks can give!

the explanation trying link objects created in 1 context have not been merged other context. no changes made in 1 context show in until context have been merged. error message telling you.

the null object caused using temporary objectids. objectid not fixed until object has been saved persistent store. until has temporary id change when saved.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -