Re: NSTableColumn & binding value
Re: NSTableColumn & binding value
- Subject: Re: NSTableColumn & binding value
- From: Kaspar Fischer <email@hidden>
- Date: Wed, 30 Mar 2005 18:26:13 +0200
Hello,
Maybe my first two mails were not so clear, so let
me try again to write down the problem. I feel the
question is interesting and of general interest.
I am trying to build a table that displays an array
of books, say. Each row represents an instance of a
class Book, and I want to show two attributes of the
book. So my table has two columns: the cells in the
first column contain simple text elements (the title
of the book, say) while the cells from the second
column contain buttons, where each button shows
either picture A or picture B (if you click the
button the publisher's website is opened, say).
My goal is to implement this using controllers and
bindings in order to write as little glue code as
possible. So what I set up is an array-controller
that manages the array of instances of class Book.
The class Book provides methods "title" and
"setTitle" (so I can set up the bindung) and also
a method "imageForButton" which returns the NSImage
to display in the button. (There's probably also
a method "link" returning the publisher's URL.)
The first column is easy: I bind the "value"
attribute of the first NSTableColumn in the
Bindings inspector in IB to my controller with
controller key "arrangedObjects" and model key
"title". That works fine.
The second column is my problem. How can I set
up the binding? Do I have to subclass NSButtonCell?
But what methods to I have to write?
Many thanks for your help,
Kaspar
P.S. The task is not the usual one (as found in
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Tasks/images.html
for example) because cells in the second column
(i.e., the NSButtonCells) are not "value cells": If
you add such a cell in IB (by dropping it onto the
column header), the NSTableColumn bindings inspector
does not "recognize" them and does not show a "value"
attribute you can bind.
_______________________________________________
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