I have an application that contains a NSTableView of Card data types. The NSTableView gets its data from an NSArray of Card instances.
I want to allow the user to be able to filter the view based on the Card fields. I know I need to use a NSPredicateEditor to present the UI for the user, and to create the NSPredicate instances. However, I cannot wrap my head around how this works, and cannot get a simple example working (with a single rule). I have spent the last two days reading up on it, and it is just not clicking for me. So, does anyone have a very simple example of how to use NSPredicateEditor programmatically? I want to be able to allow the user to potentially filter on multiple fields, but would be happy if I can get a single field to work right now. Here is the current predicate I am using with a NSSearchField: NSPredicate *namePredicate = [NSPredicate predicateWithFormat:@"cardName contains[c] %@", searchString]; [filteredCards filterUsingPredicate:namePredicate]; Card has a property (NSString) named "cardName". I have tried to programmatically add a NSPredicateEditorRowTemplate, but when I do this, nothing shows up in the editor at runtime. NSPredicateEditorRowTemplate *template = [[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions:[NSArray arrayWithObjects:[NSExpression expressionForKeyPath:@"cardName"], nil] rightExpressions:[NSArray arrayWithObjects:[NSExpression expressionForConstantValue:@"Foo"], nil] modifier:NSDirectPredicateModifier operators:[NSArray arrayWithObject:[NSNumber numberWithInt:NSContainsPredicateOperatorType]] options:NSCaseInsensitivePredicateOption ]; predicateEditor.rowTemplates = [NSArray arrayWithObject:template]; I am really stumped on this one, and would appreciate it if someone could help nudge me in the right direction. Does anyone have a simple example of how to construct NSPredicateEditorRowTemplate that will create a filter like so: cardName contains USER_INPUT I think if I can get that working, then it will put me over the hump and I can figure out the rest. mike _______________________________________________ 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