objective-ccocoanstableviewcocoa-bindingsnsformatter

Maintaining a reference to an NSFormatter in a view-based NSTableViews


I have a project that currently uses cell-based NSTableViews WITH bindings. I am updating the project to use views instead. With cells, I could instantiate a NSFormatter in code, add it to an NSTableColumn's datacell's formatter property, maintain a reference to that formatter, and change the formatter's properties programmatically. I don't see a strategy to do the same thing with view-based tableviews.

With view-based tableviews, I can set a formatter on a prototype views' textfield, but that formatter is a prototype as well. This formatter will be instantiated several times so I can't maintain a reference to a prototype formatter. As another solution, I created a custom formatter object with my formatter's class, dragged my tablecellview's outlet to the formatter, but this doesn't work at all.

I need to be able to programmatically adjust how my formatter works in a view-based tableview.


Solution

  • You can set the formatter in the delegate's tableView:viewForTableColumn:row: method.