I override many setters for my core data structures to keep much of the “business logic” in the database. What is the best way to override the setter methods for a to-many relationship within core data? It seems that the setter functions, for an relationship called ‘Things,’ include:
- (void)addThingsObject:(Thing *)value;
- (void)removeThingsObject:(Thing *)value;
- (void)addThings:(NSSet *)value;
- (void)removeThings:(NSSet *)value;
Do I need to override all four of these functions? What is the best practice for how to do this cleanly? If there is an inverse relationship, do I need to do anything within the setters to make sure that the inverse is set properly?
Take a look at MoGenerator. It creates two classes for each entity in core data, one of which you use to write custom code to manage the entity.