Re: Coredata Abstract Relations
Re: Coredata Abstract Relations
- Subject: Re: Coredata Abstract Relations
- From: Sammi Williams <email@hidden>
- Date: Mon, 27 Jun 2005 01:26:27 +1200
Regarding implementing a custom accessor:
Given that you already have this information, an easy way would be
to implement a custom class for the Bank entity that returns a
union of the bankTransaction relationship and the value for the
key path persons.personTransactions (or however you've named the
relationships).
Okay, this makes sense - is it not possible to do it with a fetched
property? Or is this basically a fetched property implemented with
custom logic?
Great, I think this is mosty sorted.
I'm curious, now I also depend on 'persons.account' from within the
Bank entity to update my 'allTransactions' union of all transactions
accessor - how can i do this with
triggerChangeNotificationsForDependantKeys ? I tried his naively
//in initialize
NSArray *keys = [NSArray arrayWithObjects: @"persons", @"account",
@"persons.account", nil];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"allTransactions"];
Thanks for any advice how to hook up this change notification!!!
Anyone interested in the allTransactions code, here it is:
- (NSSet*) allTransactions {
NSMutableSet* all = [NSMutableSet setWithSet:[self
valueForKeyPath:@"account"]];
NSSet *persons = [self valueForKeyPath:@"persons"];
id person, iter = [persons objectEnumerator];
while (person = [iter nextObject]) {
[all unionSet:[person valueForKeyPath:@"account"]];
}
return all;
}
I'm curious if there is any way to make this better by using
@unionOfSets or something rather than a while loop - I tried it but
got lots of problems and it didn't work at all.
Sammi
_______________________________________________
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