• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Doing Business Logic when a To-Many Relationship Changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Doing Business Logic when a To-Many Relationship Changes


  • Subject: Doing Business Logic when a To-Many Relationship Changes
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 9 Jun 2009 18:22:26 -0700

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 (email@hidden)

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:
This email sent to email@hidden


  • Prev by Date: Crash during printing an offscreen image view
  • Next by Date: Re: Cannot open file
  • Previous by thread: Crash during printing an offscreen image view
  • Next by thread: Cocoaheads Lake Forest will _not_ have an official meeting in June. Our next meeting is on 7/8
  • Index(es):
    • Date
    • Thread