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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to