What is an easy way to set up my NSTableView with multiple columns to only display certain data in one column. I have the IBOutlets set up, but I don’t know where to go from there.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you’re not using Cocoa Bindings/Core Data, you can display data in an NSTableView by implementing two methods from the NSTableViewDataSource protocol. Typically your controller will implement the protocol, so open the controller .m file and add these methods to the controller’s
@implementation:You need to set the table’s
dataSourceproperty to the controller. In Interface Builder control-drag from the table view to the controller and setdataSource. Now build and run and you should see your data in the table.If you only want to fill out one column, add an IBOutlet NSTableColumn* to your controller; let’s call it
explosiveColumn. In Interface Builder, control-drag from the controller to the column you want to fill in and setexplosiveColumn. Then, in tableView:objectValueForTableColumn:row: you can test if thecolumnparameter is the same object as the one that the outlet is set to:This tutorial might be useful: http://www.cocoadev.com/index.pl?NSTableViewTutorial