Question

So, is the button identifiable?

I need to identify a cell-botton (Button Cell) in aNSTableView in order to detect if it was pressed already. The table can always change by user input. My bright idea is if a created button (button cell) were unique it would be identifiable. Is that possible?

Was it helpful?

Solution

Cells are a little different from full-fledged controls. NSTableView reuses a single cell for all the rows of a column. When NSTableView draws a row, or when it handles user input, it configures the cell for the row/column in question.

It sounds like in your case you have an NSButtonCell and you want to know which row was clicked. You can determine which row was clicked by checking the table view's clickedRow property in the button cell's action method. The answer to this question explains how to do this.

OTHER TIPS

Well, as long as these buttons are subclasses of UIView, which UIButtons are, then you can use the tag field to carry a numeric information. Set the button.tag in celForRowAtIndexPath to indexPath.row and you can fetch the tag within the IBAction method that the button should inovke when pressed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top