Assuming I have created a 2DArray of buttons using the following code:
for (NSInteger rowIndex = 0; rowIndex < 6; rowIndex++)
{
NSMutableArray *rowOfButtons = [[NSMutableArray alloc] init];
for (NSInteger colIndex = 0; colIndex < 7; colIndex++)
{
CGRect newFrame = CGRectMake(2+colIndex * 45, 100 + rowIndex * 40, 45, 40);
UIButton *calButton = [UIButton buttonWithType:UIButtonTypeCustom];
calButton.frame = newFrame;
[calButton setBackgroundColor:[UIColor whiteColor]];
[rowOfButtons addObject:calButton];
[calButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:calButton];
}
[m_button2DArray addObject:rowOfButtons];
}
How do I find out the row and column of a clicked button anywhere within that grid?