You need to use NSTableViewDelegate to control what happens when you use NSTableView . If your corresponding view containing the table is called MyViewController , your interface file ( .h ) should start as follows:
@interface MyViewController : NSObject <NSTableViewDelegate> {
And then in your implementation file ( .m ) do the following:
- (id)init { [super init]; myTableView.delegate = self; return self; } - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex { NSLog(@"%i tapped!", rowIndex); return YES; }
source share