• 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
NSTableColumn subclass and custom binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableColumn subclass and custom binding


  • Subject: NSTableColumn subclass and custom binding
  • From: Alexander Lamb <email@hidden>
  • Date: Fri, 25 Aug 2006 16:58:46 +0200

Hello,

I am really not very lucky with this, I have been trying all day to implement "manually" some bindings in a custom subclass of NSTableView. The reason is, I need to implement a subclass of NSButtonCell which adds an attribute to bind (in addition to value and target). The additional attribute is color.

So, looking at the documentation and at mmalc's examples, I thought I would implement the binding at the table column level and not at the cell level. Indeed, unless special cases, table columns reuse the same cell for the whole column.

My problem is that if I bind my NSTableColumn to "arrangedObjects.color" (in my model I have a color attribute), I get notified of change (in observeValueForKeyPath...) each time a color changes but I don't know which object changed (I receive the whole array of arrangedObjects).

So, from the GraphicsBindings example of mmalc, I discovered I needed to individually register for changes each object (on the color attribute). Ok, but when I will receive the change notification, how will I know to which cell it is related. I therefore need to keep a link to the original array controller and check the position. Then from the position, I know which cell needs to change... but how do I set the color of the cell at that point? Some people on the list suggested to use "tableView willdisplayCell..." but there again I am loosing the context of the update.

Well, in summary, I am lost and this seems very complicated. WHY isn't there a single example of a custom binging for a subclass of NSButtonCell (or any cell) in a NSTableColumn (probably a subclass of).

Even if I abandonned the bindings route and used only the "tableView will display cell..." I am still stuck with updates "pushed" from the model. I would need to have my NSTableColumn subclass register for changes in all the objects displayed. Seems wrong in a way (because it really means I need to keep hold of an NSArray of objects  from the model in my NSTableColumn subclass).

Ok, sorry for the long post, but I am really stuck at this point. I also tried to trace more or less what is happening for "normal" bindings set in IB but I don't understand much (it appears for example that NSCell used in a table view are never bound to anything... only the table column is).

Thanks for any hint,

Alex
 _______________________________________________
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

  • Prev by Date: Re: Core Data document-based app design decision?
  • Next by Date: Re: Re: iTunes and AppleScript
  • Previous by thread: Re: Problem with Cocoa App on FAT32-formatted external drive
  • Next by thread: Re: NSTableColumn subclass and custom binding
  • Index(es):
    • Date
    • Thread