objective-ccocoanscellnsmatrix

Getting the column and row of an NSCell in an NSMatrix in Cocoa


Given an NSMatrix and an NSCell is there a quick way to query the matrix to know at which row and column in the matrix the cell is placed. I would like to know this upon receiving action messages from NSActionCells.

The only way I can see of doing it is to loop through the rows and columns of the matrix and check for equality with the message sender, or give tags to the cells based on their position, which is ugly. I'm sure there's a better way of doing this, isn't there?


Solution

  • You can ask the matrix which row and column a cell is at.