Re: Subclassing NSCell: Checkbox and Text?
Re: Subclassing NSCell: Checkbox and Text?
- Subject: Re: Subclassing NSCell: Checkbox and Text?
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 6 Jun 2004 02:08:13 -0700
On Jun 4, 2004, at 1:25 AM, Jamie wrote:
I am looking to make a custom subclass of NSCell to display a checkbox
and a text label value in an NSOutlineView, much like the interface on
Apple's installer application. [...] What don't understand, is how you
would then get your NSArrayController to use that object with
bindings.
Firstly, NSOutlineView does not currently support bindings...
" The ImageAndText cell requires two variables to be set; you can only
bind a single value. If the value contained both the text and the
image (for example in a dictionary) that would work (assuming the
ImageAndTextCell knew the keys to use to extract the information from
the dictionary)."
I understand that. So I am guessing that you would override
-setObjectValue / -objectValue, and then point the image and text
accessors / setters to lookup the relevant key the dictionary (if that
was the object you were now using in setObjectValue). That way KVB
can look each element OK. So now we would have a way of
programatically setting each value individually, or both together and
also to retrieve them in the same ways.
What don't understand, is how you would then get your
NSArrayController to use that object with bindings. I don't actually
want to be able to change the label from the outline view, just the
selected state, so effectivly I only want to bind the checkbox value
to my array - but it would be nice to know how to bind each value
independently. From my understanding, I would have to bind my
NSArrayController to my custom cell programatically if I wanted to be
able to set each value separately.
I'm not sure why the array controller cannot be used "as is" (modulo
point above)?
If this were using a table view, I would imagine that you would have an
array of objects managed by the array controller. One of the instance
variables of the object would be a dictionary, with keys, say, "name"
and "checked". If the dictionary variable's name is "dictionary," then
you would bind the 'value' of the table column to
[Array Controller].arrangedObjects.dictionary
It would be up to the cell to extract the relevant information from the
dictionary (see
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/
20002373/196748>. What's not immediately clear, however, is how well
this will play if the dictionary is mutable. I'm not sure offhand how
easy it would be to get the table view to update if the values for the
keys can be changed independently of the dictionary itself (given that
by default the dictionary is observed, not its contents).
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.