• 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
Re: Observing Managed Object Changes. Was: Strange ... behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Observing Managed Object Changes. Was: Strange ... behavior


  • Subject: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 25 Feb 2009 14:16:11 -0800

Well, now that I've convinced myself that NSManagedObjectContextObjectsDidChangeNotification does not give enough information, and that there is no way to reliably maintain a KVO observer of a managed object, I was going to bite the bullet and implement custom setters for all the properties I want to observe, slipping in the posting of a notification, like this:

- (void)setFoo:(NSWhatever*)value
{
    [self willChangeValueForKey:@"foo"];
    [self setPrimitiveFoo:value];
    [self didChangeValueForKey:@"foo"];

NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
value, @"NewValue",
@"foo", @"key",
nil] ;
[[NSNotificationCenter defaultCenter] postNotificationName:@"ModelHit"
object:self
userInfo:userInfo] ;


}

For attributes, I believe it is guaranteed that any proper KVO- compliant change to a Foo will use this accessor and thus my notification will be posted whenever an attribute value changes.

But what about to-many relationships? Think DepartmentAndEmployees. Imagine I have a OrgChart object. My OrgChart wants to receive a notification, observation, or SOMETHING when the directReports of any Employee is changed.

How can I get this? According to the documentation, a to-many relationship is ordinarily modified by mutating the mutable set proxy. So there is no always-invoked accessor to override.

Certainly there must be a solution to this very basic problem. What is it?

Thanks,

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


  • Follow-Ups:
    • Re: Observing Managed Object Changes. Was: Strange ... behavior
      • From: Quincey Morris <email@hidden>
References: 
 >Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Karolis Ramanauskas <email@hidden>)
 >Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Jerry Krinock <email@hidden>)
 >Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Dave Fernandes <email@hidden>)
 >Observing Managed Object Changes. Was: Strange ... behavior (From: Jerry Krinock <email@hidden>)
 >Re: Observing Managed Object Changes. Was: Strange ... behavior (From: Quincey Morris <email@hidden>)
 >Re: Observing Managed Object Changes. Was: Strange ... behavior (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: gui development without using xcode or interface builder
  • Next by Date: Re NSTableView Cell edit values.
  • Previous by thread: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Next by thread: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Index(es):
    • Date
    • Thread