Peter,

Thanks for your response (I was hoping you would notice my post :-).

My interpretation of your response is as follows:
1- Cocoa bindings are not supported for popup views that are used in a NSPredicateRowtemplate, even if I am careful to make sure that the view is re-bound (via copyWithZone) when NSPredicateEditor creates its copies. This is true in spite of the fact that I managed to fill the popup via bindings upon initial creation. 2- One needs to observe the appropriate objects using KVO and then take the steps you outlined below in order to ensure that the popup has current values.

Can you please confirm my understanding?

Thanks,
Martin


On 22-May-09, at 10:55 PM, Peter Ammon wrote:


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 (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 arch...@mail-archive.com

Reply via email to