Method creation starts when a row is selected as a table

How can I call a method when a row is selected in a table view?

+4
source share
3 answers

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; } 
+6
source

Here is a link to NSTableViewDelegate docs .

+2
source

Am I missing something? Just call it in the following delegate method: didSelectRowAtIndexPath

-5
source

All Articles