I am new to master data, so I have a few questions. I will ask two
1) I have two objects named Team and TeamMembers. They have many relationships, i.e. One team can have many members. First of all, look at the diagram and .h files with such models and tell me if I managed to establish the right relationship between Team and TeamMembers (I have the feeling that I made the opposite relationship).

Teams.h
TeamMembers.h
2) Please, I need a sample code to insert a team and then insert its team members. Also how to get team members of a particular team.
EDITED I use the following code snippet to insert teams and team members into groups, but it does not return all team members to NSSet. It returns only one member of the team in the result set.
self.context = [del managedObjectContext]; Teams *teamobj = [NSEntityDescription insertNewObjectForEntityForName:@"Teams" inManagedObjectContext:context]; teamobj.team_name = teamname.text; teamobj.color = [NSString stringWithFormat:@"%d", color]; teamobj.points = [NSString stringWithFormat:@"%d", 0]; for(UITextField *view in self.scrollview.subviews) { if([view isKindOfClass:[UITextField class]]) { if ([view tag] == 99) { if (![view.text isEqualToString:@""]) { noone = YES; TeamMembers *teammember = [NSEntityDescription insertNewObjectForEntityForName:@"TeamMembers" inManagedObjectContext:context]; teammember.member_name = view.text; teammember.teams = teamobj; [teamobj addMembersObject:teammember]; } } } } if (![context save:&error]) { NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" message:@"Unable to save team at the moment." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; [alert show]; [alert release]; }
Ayaz Alavi
source share