iphone - ios/core data - saving entity for a specific entity object -
i got qeustion core data , rules of relationships.
i have entitie multiple users. users have optional one-to-many relationship entitie called event. on app start create user (i self) , other users , save them in cd. object of user i m, hold in nsuserdefaults.
so, created event , want assign userobject entitie saved in core data. thought use user object saved in userdefaults , add event it, here:
event *event = (event *)[nsentitydescription insertnewobjectforentityforname:@"event" inmanagedobjectcontext:managedobjectcontext]; //property setters event.createdby = userobjectfromnsuserdefaults;
is right way? assign event specific user (in example me) ?
another qeustion is:
my event class (subclass of nsmanagedobject) has nsset property add , remove methods add/remove invitedusers or acceptedusers event. how use methods right?
any gets cookie :=)
about first question - yes, thats way make relationships in core data. assign specific object (nsmanagmentobject, yes?) property.
the other way day that, if it's 1 many,
[userobjectfromnsuserdefaults addevent:event];
again, if management object.
the problem see here, save in nsuserdefualts. means when load there, not attached moc, , guess won't work. need save id or in nsuserdefaults, not object itself. when app loads, fetch object db using id.