• 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: Core Data Relationship Binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: (no subject) (From: John Timmer <email@hidden>)
 >Re: Core Data Relationship Binding (From: Niels Meersschaert <email@hidden>)

  • Prev by Date: kerning broken on Tiger
  • Next by Date: Re: Manual KVO and will/didChangeValueForKey
  • Previous by thread: Re: Core Data Relationship Binding
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread