Re: NSPredicateEditorRowTemplate, NSPopupButton and bindings
Re: NSPredicateEditorRowTemplate, NSPopupButton and bindings
- Subject: Re: NSPredicateEditorRowTemplate, NSPopupButton and bindings
- From: Peter Ammon <email@hidden>
- Date: Fri, 22 May 2009 19:55:02 -0700
On May 22, 2009, at 9:37 AM, Martin Stanley wrote:
I've finally got the hang of NSPredicateEditor and custom
NSPredicateEditorRowTemplates. (It sure took a while and many, many
searches and head-scratchings). However, I am stuck on one thing and
I suspect that the problem might lie in the NSPredicateEditor code
itself; hence this post.
Here is what I am trying to do:
I have a Core Data document-based application for managing Tasks (to-
do items). I am using NSPredicateEditor to manage a set of user-
defined Smart Groups. I want the user to be able to build a
predicate based on a choice from a popup button. For example the
(sub-)predicate might look like this:
status == "Not Started"
Implementing this is straightforward enough, but I the wrinkle is
that want the right hand side of the expression to come from a core
data entity. So, no problem, when I create the NSPopUpButton (in my
custom NSPredicateEditorRowTemplate class) I simply fill the
menuitems from the appropriate array controller, which in turn gets
its data from the Core Data entity. After much learning and
experimenting, this now works. All is well.
So, then I realize that if (in another window) the user edits the
Core Data entity in question, the changes are not reflected in the
NSPredicateEditor popup. Okay, this seems like a candidate for cocoa
bindings. Again, after much searching and experimentation I come up
the following:
Hi Martin,
NSPredicateEditor does not support editing the popups like this. What
you should do, when the available values in the popup need to change,
is create a new NSPredicateEditorRowTemplate that reflects the change,
and set it on the NSPredicateEditor in place of the old one, with
setRowTemplates:
I think you may also need to save off the predicate editor's object
value first, and then set it back on after calling setRowTemplates:.
_______________________________________________
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