views:

30

answers:

1

I'm having a really weird problem. I'm trying to put an NSPredicateEditor into my interface using IB, and when I build the app it just shows up as an empty gray rectangle. This is without my applying ANY CHANGES WHATSOEVER to the defaults, including not modifying the default templates. What could possibly be going on?

+2  A: 

NSPredicateEditor works best when you bind it to some property (like an NSArrayController's filterPredicate).

The template you set up in IB is only to allow you to define the limitations of the rules (such as allowing the user to choose "first name" or "last name") but does not define what appears when the control is "live."

To modify an "empty" editor (array controller filter predicate or otherwise), connect a button or menu item's action to the editor view's -addRow: action. At runtime, clicking this will add an initial "rule" (following the constraints you specified in your IB template). You can even test that in IB itself.

Joshua Nozzi
+1 the answer is "you need to invoke `addRow:`", but the other information is quite useful too. :)
Dave DeLong
I kind of sympathize as I recognized the source of the confusion pretty much right away - I went through it myself when first exploring the control. :-) It was twofold: a) why doesn't this "default predicate" behave correctly and b) why does it go away at runtime?
Joshua Nozzi
@Joshua agreed; I spent a good month or so figuring out how NSPredicateEditor works; It's not a very thoroughly documented control.
Dave DeLong