Tableview, custom NSCell (with multiple items) and bindings
Tableview, custom NSCell (with multiple items) and bindings
- Subject: Tableview, custom NSCell (with multiple items) and bindings
- From: zeno <email@hidden>
- Date: Thu, 22 Sep 2005 00:43:14 +0200
I have tableview that displays a list of managed objects (core data)
via an array controller (bindings): the table has 3 columns to display
3 attributes of the managed objects' entity. (2 of the 3 columns have
non-textual datacells, one uses a buttoncell to display checkboxes,
the other an imagecell). Everything works like a charm.
Now I'd like to improve the GUI of the table by grouping the 3 columns
into a single custom cell (a single column where each row shows all
the 3 attributes in a custom cell).
How would you set up the bindings?
Here is what I did:
- I subclassed NSCell to do my custom drawing
- I set the table column's data cell to my custom cell
- I bound the table column to the arraycontroller -> arrangedObjects
(leaving "Model Key Path" empty) with a custom Value Transformer (see
below)
- I implemented a Value Transformer that takes the managed object (got
from the arrangedObjects binding above) and returns a custom object
containing only the info I need to draw my cell (for the record, the
object returned by the value transformer is the one that is set
through setObjectValue -which I've overridden- in my NSCell subclass,
and that's where I'll find the data to do my custom drawing)
The problem of having set up the binding with arrangedObjects alone
(without specifying an attribute as model key path) is that changes
occurring to one of the 3 attributes of a managed object are not now
being reflected in my custom cell... unless I manually click on the
tableview to change selection (forcing the cell to redraw).
Any ideas? How should I have implemented it?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden