In my app I have this code to update a DB:
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchRequest=[NSFetchRequest fetchRequestWithEntityName:@"Struct"];
NSError *error = nil;
for (id element in array){
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"id==%@",[element objectForKey:@"id"]]];
Struct *struct = [[context executeFetchRequest:fetchRequest error:&error] lastObject];
if (struct != nil){
//updating value of attributes
struct.name = [element objectForKey:@"n"];
struct.val = [element objectForKey:@"val"];
struct.pos = [element objectForKey:@"pos"];
}
else{
//create a new identity
}
}
it's all ok but I have other two objects in relationship with Struct:
"Id_Loc" (one to many) "Details" (one to one)
I don't know how to update them, I don't know how to call them from my object 'Struct' I don't find nothing Can you help me? thanks