Re: Fetching entities where the relations are known (rakel)
Re: Fetching entities where the relations are known (rakel)
- Subject: Re: Fetching entities where the relations are known (rakel)
- From: rakel <email@hidden>
- Date: Thu, 12 Oct 2006 14:04:01 +0200
The reason the predicate didn't work, was that my currentPerson
object was NOT the NSManagedObject instance I thought it was, it was
a proxy (an instance of the class _NSControllerObjectProxy as it
turned out) which I received from the selection in an
NSArrayController. (According to the documentation it shall be
possible to use the predicate I described, but this of course
requires the correct objects :-)
Now, the question is as follows, given an NSPopUpButton, bound to an
NSArrayController which in turn is bound to a ManagedObjectContext,
how do I get an NSManagedObject instance corresponding to the
selected item in the popup?
Regards/Dan
Från: rakel <email@hidden>
Datum: tisdag 10 okt 2006 23.13.06 GMT+02:00
Till: email@hidden
Ämne: Fetching entities where the relations are known
I have a Core Data model, which looks something like [Person] ----*
[Value] *---- [Variable] I.e. the Person entity has a to-many
relation to the Value entity, and the Variable entity also has a to-
many relation to Value. Value in turn has a to-one relation with
both Person and Variable (and before anyone asks, no, this is not a
"many to many"-relational table as seen in ordinary relational
databases).
Also, the Value entity has a date attribute, called assessmentDate.
Now, in my application I have a Person instance and a Variable
instance. How do I get all the corresponding Value instances,
sorted on assessmentDate?
I have been trying around with fetch predicates, with no success
( [NSPredicate predicateWithFormat:@"personr == %@",
currentPerson ] does not do the trick). Another idea could be to
ask the Person for the set of all its Values and then the Variable
for the set of all its Values, and then to take the union of those
two sets -- but this won't sort the Values.
Regards /Dan
_______________________________________________
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