Re: Triggering a Method when a Core Data Property is Altered.
Re: Triggering a Method when a Core Data Property is Altered.
- Subject: Re: Triggering a Method when a Core Data Property is Altered.
- From: Joshua Garnham <email@hidden>
- Date: Wed, 7 Oct 2009 10:22:08 -0700 (PDT)
Hi,
That works now, Thanks Very Much!!!
Josh.
________________________________
From: Volker in Lists <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: email@hidden
Sent: Wednesday, 7 October, 2009 18:04:59
Subject: Re: Triggering a Method when a Core Data Property is Altered.
Hi,
awakeFromFetch is only called when the object is loaded from the persistent store (=fetched). So all newly inserted objects are not observed.
this might be one reason for not getting triggered for rows 2/3 if they were not fetched but created. Otherwise I have no idea why it doesn't work yet-
Volker
Am 07.10.2009 um 18:54 schrieb Joshua Garnham:
Hi,
>
>Ok, I have changed it to awakeFromInsert: and have removed the observer in the NSManagedObjects dealloc: method.
>And have already fixed the performSelector: problem.
>
>So the NSManagedObject sub-class looks like …
>
>- (void) awakeFromFetch {
> [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
>}
>
>- (void)dealloc {
> [self removeObserver:[NSApp delegate] forKeyPath:@"name"];
> [super dealloc];
>}
>
>
>… and the App Delegate …
>
>- (void)observeValueForKeyPath:(NSString *)keyPath
> ofObject:(id)object
> change:(NSDictionary *)change
> context:(void *)context {
> [self performSelector:@selector(doSomthing:)];
>}
>
>It builds without any warnings but it only half works.
>What happens is as follows …
>In my table view I have added three rows, each have text fields bound to the 'name' property.
>The method is triggere when I change the text for the first row however it is not triggered when I change the text for the
>other rows. Do you have any idea why this is?
_______________________________________________
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