Skip navigation.
 
ml(CoreData) Saving Predicates in SmartGroups
FROM : Chris Blunt
DATE : Tue Sep 19 15:51:35 2006

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

Related mailsAuthorDate
No related mails found.