With a one-to-many relationship: the generated classes from the xcdatamodel will have:
@interface Department (CoreDataGeneratedAccessors)
- (void)addEmployeeObject:(Employee *)value;
- (void)removeEmployeeObject:(Employee *)value;
- (void)addEmployees:(NSSet *)value;
- (void)remove Employees:(NSSet *)value;
@end
Would 'addEmployees' replace all existing items in the set or will it append to the existing list?
Apple's CoreData Programming Guide notes that you can "manipulate an entire to-many relationship in the same way you do a to-one relationship" and demonstrates it using 'setEmployees' and not the 'addEmployees' that my generated class has.
NSSet *newEmployees = [NSSet setWithObjects:employee1, employee2, nil];
[aDepartment setEmployees:newEmployees];
NSSet *newDirectReports = [NSSet setWithObjects:employee3, employee4, nil];
manager.directReports = newDirectReports;
// for adding single elements
NSMutableSet *employees = [aDepartment mutableSetValueForKey:@"employees"];
[employees addObject:newEmployee];
[employees removeObject:firedEmployee];
// or
[aDepartment addEmployeesObject:newEmployee];
[aDepartment removeEmployeesObject:firedEmployee];