• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom NSPredicateEditorRowTemplate with Single Item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSPredicateEditorRowTemplate with Single Item


  • Subject: Re: Custom NSPredicateEditorRowTemplate with Single Item
  • From: Peter Ammon <email@hidden>
  • Date: Mon, 19 May 2008 15:58:08 -0700


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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Custom NSPredicateEditorRowTemplate with Single Item
      • From: Steven Huey <email@hidden>
References: 
 >Custom NSPredicateEditorRowTemplate with Single Item (From: Steven Huey <email@hidden>)

  • Prev by Date: Re: Initialize a subclass object with a base class object
  • Next by Date: Re: Initialize a subclass object with a base class object
  • Previous by thread: Custom NSPredicateEditorRowTemplate with Single Item
  • Next by thread: Re: Custom NSPredicateEditorRowTemplate with Single Item
  • Index(es):
    • Date
    • Thread