Re: Triggering a Method when a Core Data Property changes.
Re: Triggering a Method when a Core Data Property changes.
- Subject: Re: Triggering a Method when a Core Data Property changes.
- From: Joshua Garnham <email@hidden>
- Date: Sat, 17 Oct 2009 11:55:01 +0000 (GMT)
Hmm. Ok.
Could I sub class NSManagedObject then add the following code to make it observe objects as they are added or fetched?
- (void) awakeFromFetch {
[self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
}
- (void) awakeFromInsert {
[self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
}
But how would I trigger an action when the name property changes?
Cheers,
Josh.
________________________________
From: Kyle Sluder <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: email@hidden
Sent: Friday, 16 October, 2009 19:02:10
Subject: Re: Triggering a Method when a Core Data Property changes.
On Fri, Oct 16, 2009 at 10:57 AM, Joshua Garnham
<email@hidden> wrote:
> I am trying to trigger a method when A Core Data property is
> changed, e.g A Text Fields Text in a Table (connected to Core Data) is
> changed. Basically I want to be Key Value Observing the CD 'name' property of all
> the objects in my Tree Controller, so that when the 'name' property of
> one of my objects is changed it triggers an action. How would I do this though?
You need to observe each object as it is added to the tree controller.
This means observing the arrangedObjects property of the tree
controller, using that change notification to observe the children
property of the arrangedObjects proxy, using those change
notifications to observe the children property of each of those
objects, and so on.
--Kyle Sluder
_______________________________________________
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