Re: archiving a predicate
Re: archiving a predicate
- Subject: Re: archiving a predicate
- From: Matthew Firlik <email@hidden>
- Date: Sun, 25 Jun 2006 11:32:27 -0700
On Jun 25, 2006, at 11:21 AM, John R. Timmer wrote:
I tried to use an NSValueTransformer to convert an NSPredicate to
data, but it doesn't seem to work (the following gets logged:
"exception: *** -encodeObject:forKey: only defined for abstract
class. Define -[NSArchiver encodeObject:forKey:]!"). I could break
the predicate down into format string and the values to substitute,
but it's supposedly NSCoding compliant. Any advice on how to handle
this?
Keyed-archiving will work just fine. You can see code for this in the
CoreRecipes example (http://developer.apple.com/samplecode/CoreRecipes/index.html
), in the "SmartGroup" entity. That entity uses a persistent NSData
attribute and a transient NSPredicate attribute to approximate
smartgroup functioanlity. The encoding methods is as simple as:
NSData *predicateData = [NSKeyedArchiver
archivedDataWithRootObject:yourPredicate];
and the decoding is also straightforward:
NSPredicate *yourPredicate = [NSKeyedUnarchiver
unarchiveObjectWithData: predicateData];
- matthew
_______________________________________________
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