Adding more info to @JimPuls answer for other new to Cocoa.
- IBOutlet for NSTableView must be declared in the interface. I suggested that this is preferable to do in the table delegate.
- IBOutlet to the table must be connected via Interface Builder. To do this, drag Ctrl and drag to IB from the class that declares the output as a table. When you release the mouse, a pop-up should appear with the name of the outlet that you specified in step # 1. Select this.
- In the @implementation section of the -awakeFromNib method, call -setTarget: and -setDoubleAction: on the IBOutlet declared in step # 1 and connected to step # 2.
Here is an excerpt from my table. I have my delegate, which is also configured as a data source, so you will see the NSTableViewDelegate and NSTabeViewDataSource interfaces associated with it.
// Excerpt for the interface.
@interface MyTableViewDelegate : NSObject <NSTableViewDelegate, NSTableViewDataSource> {
// Excerpt for implementation.
@implementation MyTableViewDelegate @synthesize tableOutlet = _tableOutlet; - (void)awakeFromNib { [_tableOutlet setTarget:self]; [_tableOutlet setDoubleAction:@selector(doubleClick:)]; } - (void)doubleClick:(id)object {
Hope this helps.
amateur barista Dec 04 '11 at 10:14 2011-12-04 22:14
source share