cocoa - How to setup bindings for NSPopUpButton -
i want bind selection of nspopupbutton 1 of predefined values. make simpler, imagine blog app: i'd have blogpost , category entities (core data, although doesn't matter) , each blogpost object has link 1 of category objects (through category property).
i want have user change category through nspopupbutton, in xib, have nsarraycontroller holds possible categories , bind button's content values to:
- bind to: categoriesarraycontroller
- controller key: arrangedobjects
- model key: title
this nicely populates pop titles of categories. can bind selected object to:
- bind to: blogobjectcontroller (or directly
blogobject) - controller key: selection
- model key: category
this works , correct category selected in pop up, changing selection doesn't change category under blog post filed, instead changes title of post category selected value.
given above bindings makes sense, next step change binding of pop up's content values arrangedobjects (no model key), selected object. works , changing selection indeed change category of blog post one. but doesn't show category title in pop menu, instead shows description of category (which in core data ends <category 0x1002b6990> (entity: category; id: .......).
which makes sense, introduced custom nsvaluetransformer (non-reversible). fixes item descriptions in pop menu, selection doesn't work. tried using transformer on selected object binding, disables pop entirely (perhaps reverse transform required, substantially complicate transformer).
am missing obvious - possible achive entirely bindings, without introducing additional code on controller layer?
any though welcome!
ps: hope above text makes sense :)
i try follows:
of nspopupbutton:
- bind content : categoriesarraycontroller controllerkey:
arrangedobjects - bind content values : categoriesarraycontroller controllerkey:
arrangedobjectsmodel key path: title - bind selected object : blogobjectcontroller controllerkey:
(empty)model key path: content.category
Comments
Post a Comment