• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: archiving a predicate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >archiving a predicate (From: "John R. Timmer" <email@hidden>)

  • Prev by Date: archiving a predicate
  • Next by Date: Re: Objective-C++ Exceptions (was: PICT control problems)
  • Previous by thread: archiving a predicate
  • Next by thread: Re: Objective-C++ Exceptions (was: PICT control problems)
  • Index(es):
    • Date
    • Thread