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
previous month october 2006 next month
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today