I can create an NSPredicate easily using an NSPredicateEditor (a subclass of NSRuleEditor). What I'd like to know is this:
How can I take an existing NSPredicate (one created by the editor) and reload it into the editor so that I can alter it?
EDIT: I tried @John's suggestion of using setObjectValue:, but that didn't quite work. Let me explain my set up a bit more:
I've got a Document-based cocoa app, and the Document window just has an NSPredicateEditor on it. In the dataOfType:error:
method, I have:
NSPredicate * pred = [predicateEditor objectValue];
NSData * predicateData = [NSKeyedArchiver archivedDataWithRootObject:pred];
return predicateData;
In the readFromData:ofType:error:
method, I have:
NSPredicate * pred = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[predicateEditor setObjectValue:pred];
return (pred != nil);
I've verified that the predicate is getting correctly archived and unarchived, but after opening a saved predicate, the predicate is not loaded into the predicateEditor. (Yes, predicateEditor is hooked up as an IBOutlet)