Say you have a Core Data object called Workshop. It has a to-many relationship to a Student object.
How would I create an NSArray of the students within the Workshop?
These relationships are normally declared as an NSSet
in your NSManagedObject subclass, like this:
@property (retain) NSSet* students;
And there's also some special accessor methods:
- (void)addStudentsObject:(NSManagedObject *)value;
- (void)removeStudentsObject:(NSManagedObject *)value;
- (void)addStudents:(NSSet *)value;
- (void)removeStudents:(NSSet *)value;
NSSets are similar to NSArrays, but they are not ordered, since Core Data does not guarantee a special sort order for managed objects.