The value of a to-many relationship is a NSSet
, not an NSArray
. But you can use
the generated Core Data accessor methods to add an element to a to-many relationship.
For example:
User *user = ...;
Group *group = ...;
// Add user to group:
[group addUsersObject:user]; // (1)
// Or, alternatively, add group to user:
[user addGroupsObject:group]; // (2)
(You can do either (1) or (2). If the relationships are defined as inverse relationships of each other, one automatically implies the other.)