Question

i was just wondering how to set a NSTableCellView to show a specific string depending on what option a user selected from a NSPopUpButton, any and all help would be greatly appreciated…

I would like to do this without using binding also

Was it helpful?

Solution

First, make sure you understand the Model-View-Controller design pattern. You need to do three things:

  1. Create a data structure to store your model.
  2. Have the NSTableView display the state of the model.
  3. Have the NSPopUpButton change the model.

Also, why do you want to do this without bindings? Bindings are often simpler and easier than creating your own NSTableViewDataSource. For some complex problems you have to do the work yourself, but if bindings will solve the problem, they are often the best solution.

OTHER TIPS

Maybe I dont understand you correctly but wouldnt it be the easiest way to just implement what is needed for NSTableViewDataSources, that is

-numberOfRowsInTableView
-tableView:objectValueForTableColumn:row

and return to your Table View, what might be needed. As far as I know, this even works with your NSTableCellView.

You could use the IBAction your Button causes and use

reloadData

on the Table View.

By the way, usually Table Views are intended to show large amounts of data. If you only want to show a short statement depending on the button selection consider using a NSTextField instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top