Instead of subclassing NSTableView, you can simply create a category. In the header file of your view controller ( MyViewController.h or any file with IBOutlet associated with the table view), declare a new category:
@interface NSTableView( OneClickEdit )
- (void)singleClickEdit: (id)sender;
@end
@interface MyViewController : NSViewController
{
IBOutlet NSTableView *tableView;
...
Then, in the corresponding .m file ( MyViewController.m ) add a schema implementation outside of the MyViewController implementation itself and make this new method the method of action of your table view in viewDidLoad your view controller:
@implementation NSTableView( OneClickEdit )
- (void)singleClickEdit: (id)sender
{
[self editColumn:[self clickedColumn] row:[self clickedRow] withEvent:nil select:YES];
}
@end
@implementation MyViewContoller
- (void)viewDidLoad
{
[super viewDidLoad];
[tableView setAction:@selector(singleClickEdit:)];
....
source
share