Reputation: 155
How would I add new MinorGoal to an existing goal? And how to fetch Goal's MinorGoals?
Thanks
Upvotes: 0
Views: 103
Reputation: 801
When you generate NSManagedObject Entities, Goal
class will have an NSSet
called toMinorGoal
(assuming, your toMinorGoal
is unordered relationship). Also, XCode will generate 4 accessory methods to add/remove MinorGoal
objects to/from relationship.
If you need to fetch MinorGoals object, you would just need to get Goal
object and then access its toMinorGoals NSSet
that will contain all of its MinorGoal
objects. Alternatively, you can just fetch MinorGoal
objects, but these will return every single one of them (if you don't specify how many you want).
This is an approximate example of generated accessors XCode will provide you with:
- (void)addtoMinorGoaObject:(MinorGoal *)value;
- (void)removetoMinorGoalObject:(MinorGoal *)value;
- (void)addtoMinorGoal:(NSSet *)value;
- (void)removetoMinorGoal:(NSSet *)value;
Upvotes: 1