What are the correct bindings for an NSComboBox for use with Core Data

Posted by theMikeSwan on Stack Overflow See other posts from Stack Overflow or by theMikeSwan
Published on 2010-06-09T03:56:19Z Indexed on 2010/06/09 4:02 UTC
Read the original article Hit count: 454

Imagine if you will a Core Data app with two entities (Employee, and Department). Employees have a to-one relationship with department (department) and the inverse is a to-many relationship (employees). In the UI you can select individual Employee entities and edit the details in a detail area (there are of course other attributes and there is UI for adding and editing Department entities). When using a popup button the bindings are:

content = PopUpArrayController.arrangedObjects
content values = PopUpArrayController.arrangedObjects.name (name is an NSString)
selected object = EmployeeArrayController.selection.department.name

This allows for viewing of all departments in the popup menu, correct selection of the current Employee's department, and allows that department to be changed as expected. The goal is to change this for an NSComboBox so that the user can tab to the box and type the department name in without switching to the mouse. I have tried numerous different bindings to accomplish this. I even had it work for one run with these bindings:

content = PopUpArrayController.arrangedObjects.name
value = EmployeeArrayController.selection.department.name

At least once this worked as expected (it even added a new department when the entered text did not match any existing department). Now however it will display the available Departments and auto complete but will not update the model with the correct value when the value is changed in the combo box. If the Department is set or changed with the popup the correct department is shown in the combo box.

Does anyone know what I am missing? Thanks.

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about core-data