Peter,

On May 19, 2008, at 6:58 PM, Peter Ammon wrote:

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.

I wasn't aware of that, but will keep that in mind since I have a few other custom templates to build.

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.

This works perfectly, thanks! It hadn't occurred to me to just override templateViews and return just the first item, but I really like the approach.

Best regards,
Steven Huey

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




_______________________________________________

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