which method is called when selecting a cell in the NSTableView in Cocoa OS X?

后端 未结 5 974
灰色年华
灰色年华 2021-01-02 03:59

I have a NSTableView , i want to get the value present in the cell. I am having only one column so , i just need the row number

i can use this [tableView selectedRo

5条回答
  •  梦毁少年i
    2021-01-02 04:38

    What is tableViewController object? Only NSTableView instances respond to selectedRow. You can get current table view (the one that sent the notification) from notification's object property:

    Objective-C:

    -(void)tableViewSelectionDidChange:(NSNotification *)notification{
        NSLog(@"%d",[[notification object] selectedRow]);
    }
    

    Swift:

    func tableViewSelectionDidChange(notification: NSNotification) {
        let table = notification.object as! NSTableView
        print(table.selectedRow);
    }
    

提交回复
热议问题