I have a (Core Data) managed object Foo with a to-many relationship to Bar. I need to run some business logic whenever a Bar is added to or removed from a Foo.

So, using the handy Put Implementations on Clipboard menu item in Xcode, I implement the four methods

- (void)addBarsObject:(Bar *)value ;
- (void)removeBarsObject:(Bar *)value  ;
- (void)addBars:(NSSet *)value ;
- (void)removeBars:(NSSet *)value ;

and then at the end of each of these four methods I paste in a line that invokes my business-logic method.

It seems to work, but I wonder are these four methods sufficient to detect ^every^ KVO-compliant change that the system might make to my 'bars'? I worry about that sneaky "mutable set" accessor.

Also, it seems like alot of code -- I understand I don't have to write it -- but is there a better way to do this? I understand that a better data model might place the business logic elsewhere, but this is actually a rare edge case and I've only resorted to this technique twice in a large project.

Jerry Krinock

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to