質問

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

役に立ちましたか?

解決

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.

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top