ios - cannot add parentContext to NSManagedObjectContext, context already has a coordinator -


i have view retrieve saved entity (route *) main nsmanagedobjectcontext. want import tempcontext. following marcus zarra's examples, this:

    nsmanagedobjectcontext *moc = _route.managedobjectcontext;     nsmanagedobjectid *routeid = [_route objectid];     nspersistentstorecoordinator *psc = moc.persistentstorecoordinator;     self.tempcontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype];     [self.tempcontext setpersistentstorecoordinator:psc];     nsmanagedobject *localroute = [self.tempcontext objectwithid:routeid];     [localroute motodictionary:localroute];     self.tempcontext.parentcontext = moc; // crashes here 

everything until try set parentcontext of tempcontext main moc. error:

terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'context has coordinator;  cannot replace.' 

i understand it's telling me cannot change persistentstorecoordinator. i'm nto sure why it's telling me that. when set breakpoint, tempcontext @ different memory addres main moc. also, self.tempcontext.parentcontext nil. i'd think if it's nil, set nil parameter moc, crashes. thoughts? in advance!

for managed object context, can

  • either set persistent store coordinator, second independent moc same store,
  • or set parent context child moc,

but not both.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -