Re: Core Data Relationship Binding
Re: Core Data Relationship Binding
- Subject: Re: Core Data Relationship Binding
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 2 Jun 2005 16:48:42 -0700
On Jun 2, 2005, at 4:05 PM, Niels Meersschaert wrote:
Thanks for the feedback. Unfortunately, the text field I was
trying to connect it to was set to be NOT editable (source was the
label text field) & @count works fine for Core Data Attributes in
the test. The distinction that I was running into was if the
property was a Relationship to the entity, like addresses, standard
operator bindings don't work. The workaround is to subclass
NSManagedObject & implement the count method, but that seems to
defeat a lot of the value of the bindings/Core Data functionality.
You could also simply bind to the relationship and use a value
transformer:
SetCounter *transformer = [[SetCounter alloc] init];
[NSValueTransformer setValueTransformer:transformer
forName:@"SetCounter"];
@interface SetCounter : NSValueTransformer {
}
@end
@implementation SetCounter
+ (Class)transformedValueClass { return [NSNumber self]; }
+ (BOOL)allowsReverseTransformation { return NO; }
- (id)transformedValue:(id)aSet {
return [NSNumber numberWithInt: [aSet count]];
}
@end
mmalc
_______________________________________________
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