• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableColumn not usable with binder of class NSTextValueBinder?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableColumn not usable with binder of class NSTextValueBinder?


  • Subject: Re: NSTableColumn not usable with binder of class NSTextValueBinder?
  • From: Ron Lue-Sang <email@hidden>
  • Date: Tue, 26 Aug 2008 23:34:33 -0700

Woah.
If you really want to use a custom cell, you're gonna want a custom column as well. The bindings for the tableColumn come from the tableColumn's dataCell's available bindings. Yea, as you've found, NSActionCell has a value binding, not plain old NSCell.


But of course, nothing's as simple as it seems to be. It's not like the tableColumn asks for its dataCell's exposedBindings and then just re-expose those bindings. It's just not that simple.
Don't ask. Feel free to file a bug tho.


Developers, however, are free to do this in their NSTableColumn subclasses. So you're custom cell implements and exports an extra binding. The trick is - how do you go from your cell's binding name to a setter? You need to implement NSTableColumn's dataCellForRow: to return a fully set up dataCell - with all the values specified by the binding "put" into the datacell. Doing this is easy enough if you use the same name for the cell's binding as you would for the setter.

The reason you're seeing the exception is that you've switched out the cell out from under the tablecolumn before the binding is set up. When the tableColumn is issued the bind:… command, it falls back to the plain old KVB implementation which assumes NSTableColumn implements setValue: (KVC compliant for "value" key).

Does any of this make sense?
Possibly, you've already solved this some other way, but hopefully I've cleared up a couple of things.


On Aug 20, 2008, at 10:33 PM, Dave Dribin wrote:

On Aug 20, 2008, at 3:35 AM, Ken Ferry wrote:
FYI, you should avoid using direct subclasses of NSCell in controls on
Leopard and previous.

Well, that settles that, then. ;)

It's somewhat unfortunate, but there are many cases where messages
need to flow from a cell up to a view. If your cell isn't an action
cell, that message flow won't work. It's usually fine as long as your
cell is purely stamped out drawing. If your cell has more complicated
interactions with the user, like use of a field editor or rollovers or
what have you, you're liable to see problems with non-action cells.

This cell is just drawing, but given the bindings issue and the advice above, it looks like staying away from NSCell is a good idea, ATM.


I suspect the problem here is that NSCell and NSActionCell don't have
a value binding! Check the Cocoa bindings reference.

Well, the Cocoa bindings reference does not have an entry for either NSCell or NSActionCell. For the next best thing, I printed out the return value of -exposedBindings for both. For NSCell, we've got these bindings:


Exposed bindings: (
   editable,
   enabled,
   font,
   fontBold,
   fontFamilyName,
   fontItalic,
   fontName,
   fontSize
)

And for NSActionCell, we've got these:

Exposed bindings: (
   editable,
   enabled,
   font,
   fontBold,
   fontFamilyName,
   fontItalic,
   fontName,
   fontSize,
   value
)

Indeed, NSActionCell has a "value" binding while NSCell does not.

The information about how the bindings need to be hooked up may be
determined at design time in IB. If IB thinks you have a text cell,
you might get a binding set up in a way appropriate for a text cell.
In any case, this 'binder' thing should have a bug too, if you please.

The NSTextValueBinder error message is a bug? Or the fact that NSCell does not have a "value" binding? Or both? ;)


If you want to go the bindings route, you could implement a value
binding on your cell subclass by overriding -bind:toObject:
withKeyPath:options: and then bind at runtime. That'd probably do the
trick.

I tried this, and it does not work. In fact - bind:toObject:withKeyPath:options: never gets called in my NSCell subclass. I even called [self exposeBinding:@"value"] in +initialize, and bind:toObject:... still does not get called. Is this a different bug? It seems like I should be able to add bindings to an NSCell subclass in this way.


In any case, I'm back to subclassing NSActionCell as the way to get this working.

-Dave

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


--------------------------
RONZILLA



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTableColumn not usable with binder of class NSTextValueBinder?
      • From: Dave Dribin <email@hidden>
References: 
 >NSTableColumn not usable with binder of class NSTextValueBinder? (From: Dave Dribin <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: Dave Dribin <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: Corbin Dunn <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: Dave Dribin <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: Dave Dribin <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: "Ken Ferry" <email@hidden>)
 >Re: NSTableColumn not usable with binder of class NSTextValueBinder? (From: Dave Dribin <email@hidden>)

  • Prev by Date: re: core data hanging
  • Next by Date: Re: Anyone got a cleverer idea for a tree view protocol?
  • Previous by thread: Re: NSTableColumn not usable with binder of class NSTextValueBinder?
  • Next by thread: Re: NSTableColumn not usable with binder of class NSTextValueBinder?
  • Index(es):
    • Date
    • Thread