Pregunta

I have an app with a CoreData Database and a NSTableView.
I want to do a customCell with 3 key values from database.
So I create an NSTextFieldCell Class but the binding is only for a key value.
How I can programmatically bind a NSTableColumn with multiple key value ?

Thanks.

¿Fue útil?

Solución

Here's one way to do it which foregoes the need to create a custom cell:

1) In IB, drag over an Array Controller to your Objects sidebar. Under the Attributes Inspector, set its "Mode" to Entity Mode, fill in the "Entity Name" with the name of your entity, and check "Prepares Content". Under the Bindings Inspector, set its "Managed Object Context" to managedObjectContext.

2) In IB, convert your table to be view-based. Select the "Table View" and under the Attributes Inspector, select Content Mode: View Based and change number of columns to 1.

3) In IB, select the "Table Column" and bind its Value to the Array Controller representing your object. Controller Key should be "arrangedObjects" and leave the "Model Key Path" blank.

4) In IB, select the text field (Label) in your NSTableView cell. Bind its Value to the Table Cell View. The "Controller Key" can remain blank and set the "Model Key Path" to objectValue.whateverAttributeName

There's an awesome summary and tutorial of view-based tables at Gentle Bytes.

Tim Isted created a wonderful tutorial on how to programmatically create bindings, if that's specifically what you desire at Blog @ Tim Isted.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top