• 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: NSPredicate & Editor questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPredicate & Editor questions


  • Subject: Re: NSPredicate & Editor questions
  • From: Dave DeLong <email@hidden>
  • Date: Wed, 12 Aug 2009 16:20:32 -0600

Thanks for the info! I spent some time at NSCoder Night last night poking around with attempting to convert an NSPredicate into an NSCompoundPredicate using the TODParseKit and the BNF definition of NSPredicate grammar in the docs, then eventually gave up. =) (I figured there had to be an easier way, since this seems like a non- unreasonable thing to want to do)

Luckily, I was just pointed to the setObjectValue: approach on StackOverflow.com and have been trying to get that to work.

I've started building a test app to experiment with this. Here's what I've got:

1. Create a new Document-based Cocoa App.
2. Add an IBOutlet to MyDocument called "predicateEditor"
3. Drop an NSPredicateEditor into MyDocument.xib and connect it to File's Owner's predicateEditor outlet.
4. Add a "[predicateEditor addRow:self];" message in MyDocument's windowControllerDidLoadNib: method
5. In the dataOfType:... method, retrieve predicateEditor's objectValue, use NSKeyedArchiver to archive it, and return that as the data.
6. In the readData:ofType:... method, unarchive the data as an NSPredicate and use predicateEditor's setObjectValue: method to restore it.


If I run this, create a predicate, and save it, then it saves nicely to a file. If I then try to open that file, I can NSLog and see that the predicate is getting unarchived properly, but the predicateEditor doesn't load it. Is there anything I'm supposed to be doing besides setObjectValue:? I haven't modified the predicateEditor at all, other than to make the nesting "Compound".

Thanks!

Dave

On Aug 12, 2009, at 4:02 PM, Peter Ammon wrote:

...You can set an NSPredicate directly on an NSPredicateEditor via [editor setObjectValue:somePredicate], and it will figure out which templates to use...
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPredicate & Editor questions
      • From: Peter Ammon <email@hidden>
    • Re: NSPredicate & Editor questions
      • From: Dave DeLong <email@hidden>
References: 
 >NSPredicate & Editor questions (From: Dave DeLong <email@hidden>)
 >Re: NSPredicate & Editor questions (From: Peter Ammon <email@hidden>)

  • Prev by Date: Re: NSPredicate & Editor questions
  • Next by Date: Re: Changing font color
  • Previous by thread: Re: NSPredicate & Editor questions
  • Next by thread: Re: NSPredicate & Editor questions
  • Index(es):
    • Date
    • Thread