Bindings and Core Data question.
Bindings and Core Data question.
- Subject: Bindings and Core Data question.
- From: Carlos Rivera <email@hidden>
- Date: Fri, 7 Oct 2005 20:47:55 -0400
I have two entities specified in XCode{A, B}. A has a 1 to 1
relationship with B, while B has 1 to many. Now B(totalDistance) has
a property which is dependent on the sum of all the properties in each
A(distance). Incidentally the Core Data Programming Guide: Core Data
FAQ section of the documentation has a section which describes my
problem with a solution. So I went ahead and implemented the
solution. I added the method the following methods to B
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if([keyPath isEqual:@"distance"])
{
NSLog(@"receiving notification that the distance changed");
[self updateTotalDistance];
}
}
- (void)updateTotalDistance
{
NSNumber *totalDistance = [self valueForKeyPath:@"email@hiddennce"];
[self setTotalDistance: [totalDistance floatValue]];
}
Now in the A entity I have the following:
- (void)setB:(NSManagedObject *)value
{
[self willChangeValueForKey: @"b"];
[self setPrimitiveValue: value
forKey: @"b"];
[self didChangeValueForKey: @"b"];
[self addObserver:[self b]
forKeyPath:@"distance"
options:(NSKeyValueObservingOptionNew)
context:NULL];
}
So everything compiles just fine but when I run and I change the
distance in A I get the following error:
-observeValueForKeyPath:ofObject:change:context: only defined for
abstract class. Define -[NSManagedObject
observeValueForKeyPath:ofObject:change:context:]!
Any ideas? I usually try as hard to find a solution before posting
but I have been stuck on this one for a couple of days.
Thank You.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden