Skip navigation.
 
mlCustom NSPredicateEditorRowTemplate with Single Item
FROM : Steven Huey
DATE : Mon May 19 21:05:22 2008

Hello,

I'm trying to create a custom NSPredicateEditorRowTemplate subclass 
that has a single view, an NSPopUpButton with a single item and am 
having some trouble. Basically what I'm trying to do is create a 
predicate like the one in Apple Mail when creating a rule for handling 
e-mail in which you can select "Any Message".

In my subclass I have:

- (id)initWithView:(NSView *)view
{
    if (self = [super initWithLeftExpressions:[NSArray 
arrayWithObject:[NSExpression 
expressionForConstantValue:@"kAnyCalendar"]]
                  rightExpressionAttributeType:NSBooleanAttributeType
                                      modifier:NSDirectPredicateModifier
                                    operators:[NSArray 
arrayWithObject:[NSNumber 
numberWithInteger:NSEqualToPredicateOperatorType]]
                                      options:0]) {

        self.parentView = view;
    }
}

- (NSArray *)templateViews {
    return [self.parentView subviews]; // This returns my single 
NSPopUpButton instance
}


In my controller I have an outlet variable named predicateView set to 
a NSView in my NIB that has a single NSPopUpButton instance, and I'm 
configuring the NSPredicateEditor as follows:

[predicateEditor setRowTemplates:[NSArray arrayWithObject:
[[AnyCalendarTemplate alloc] initWithView:predicateView]]];

When I call [predicateEditor addRow:self] an exception is thrown and 
my application crashes:

2008-05-19 14:48:51.614 PredicateDebugger[15062:10b] *** Terminating 
app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'In <NSPredicateEditor: 0x1023aa0>, different number of items 
(1) than predicate template views (0) for template 
<AnyCalendarTemplate 0x105a7c0: ["kAnyCalendar"] [4] 
NSBooleanAttributeType>'

I've tried different settings for the NSPredicateEditor in IB, and 
also tried returning more than one view or type of view in my custom 
row template, all without luck.

Does anyone have any sample code or suggestions to help me get this 
working?

Thanks,
Steve

--
Steven Huey Software - http://www.stevenhuey.com

Related mailsAuthorDate
mlCustom NSPredicateEditorRowTemplate with Single Item Steven Huey May 19, 21:05
mlRe: Custom NSPredicateEditorRowTemplate with Single Item Peter Ammon May 20, 00:58
mlRe: Custom NSPredicateEditorRowTemplate with Single Item Steven Huey May 20, 13:34