ios - MagicalRecords: Can't save simple relationship -


i'm new magicalrecord may simple thing i've looked everywhere answer , no 1 seems having issue. have simple core data structure 1 parent leading many child object relationship children 1 way, , parent other.

as expected works...

parent *parent = [parent mr_createentity]; parent.name = @"john";  child *child1 = [child mr_createentity]; child.name = @"paul";  parent.children = [nsset setwithobject:child]; // or child.parent = parent;  [[nsmanagedobjectcontext mr_contextforcurrentthread] mr_savetopersistentstorewithcompletion:nil]; 

i generate tableview of children belonging 1 parent, , again works fine. clicking on row takes controller displays selected child's details. controller has 2 properties passed table: parent table belongs to, , child clicked.

i have save button changes made details. triggers following:

self.child.parent = self.parent; /*    other details of child  */     [[nsmanagedobjectcontext mr_contextforcurrentthread] mr_savetopersistentstorewithcompletion:nil]; [self.navigationcontroller popviewcontrolleranimated:yes]; 

but error

coredata: error: serious application error.  exception caught during core data change processing.  bug within observer of nsmanagedobjectcontextobjectsdidchangenotification.  left hand side or operator must either nsarray or nsset. userinfo (null) 2013-05-09 17:30:17.312 notemd[37109:c07] __70-[nsmanagedobjectcontext(magicalsaves) mr_savewithoptions:completion:]_block_invoke21(0x815f750) unable perform save: left hand side or operator must either nsarray or nsset. 

i same error whatever try (such [self.parent addchildobject:self.child] or using existingobjectwithid local versions of self.parent , self.child).

i guess i'm misunderstanding how set relationships in magicalrecord i'm running out of things try....

edit: core data setup. tried simplify above patient parent, , check child (with patient = parent , checks = children).

core data setup

also, in app delegate init via

[magicalrecord setupcoredatastack]; 

also, if nslog self.child, or self.parent in detail view, both right objects.

you saving wrong context. contextforcurrentthread: deprecated doesn't return proper context. when save wrong context can saves aren't working. suggest being explicit context you're using in object creation using incontext: parameter , them save context mr_save method


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -