Search code examples
objective-ccocoanstableviewnspopupbutton

Set contents on NSTableViewCell depending on NSPopUpButton


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


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.