On May 19, 2008, at 12:05 PM, Steven Huey wrote:

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".

....

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>'

Hi Steven,

You're probably receiving this (admittedly opaque) error because you're not implementing the NSCopying protocol. Since a predicate editor can have multiple, identical rows, your templates are copied before their views are added to the predicate editor. If you subclass NSPredicateEditorRowTemplate and add a view to it, you must ensure that each copy has a new instance of the view.

However, there's an easier way to create a one-popup template:

- Select the row template in IB
- In the inspector, configure the row template to have whichever left expression type you want to have appear in your predicate (key paths or constant values). - Double click on the popup in the template, and give it whatever title you want. - Create a subclass of NSPredicateEditorRowTemplate, and override templateViews to only return the first view:

- (NSArray *)templateViews {
return [NSArray arrayWithObject:[[super templateViews] objectAtIndex:0]];
}

- In IB again, change the row template's class to your subclass.

Hope that's clear.  Let me know if you have any questions.

-Peter

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to