(CoreData) Saving Predicates in SmartGroups

  • Hi,

    I have two entity-types: Person and Record. I also have an entity
    SmartGroup which contains a predicateData (Binary) attribute, as
    given in the CoreRecipes sample app.

    For simple predicates, such as "Person.name='chris'", this setup
    seems to work OK. However, I would like to be able to add SmartGroups
    that fetch 'All records belonging to {a Person}', so the SmartGroup
    becomes an abstract representation of a Person. By attempting to
    create the SmartGroup using a predicate such as:

    ...

    [fetchRequest setEntity:recordEntity];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"owner == %
    @", personEntity];

    ...

    NSData *predicateData = [NSArchiver
    archivedDataWithRootObject:predicate];

    ...

    the NSarchiver attempts to encodeWithCoder: the NSManagedObject that
    is being referenced (in this case, personEntity). Whilst I can see
    from documentation that Core Data objects can be encoded in this way,
    something tells me this isn't right way to go about doing this, as it
    would potentially mean encoding a lot of the object graph into the
    predicateData.

    Is there a better way of making SmartGroups that reference other
    entity instances in the object graph?

    Thanks!
    Chris
    --
    www.chrisblunt.com
previous month september 2006 next month
MTWTFSS
        1 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  
Go to today
MindNode
MindNode offered a free license !