Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the index of an array?

I have an NSMutableArray instance, named myArray. It contains 8 button objects. How can I get the index of the button which I have taped to a integer variable?

like image 705
Shaan Avatar asked Jan 26 '26 01:01

Shaan


1 Answers

NSArray has a method called indexOfObject

- (IBAction)pushButton:(id)sender {
    NSButton *button = (NSButton *)sender;
  NSUInteger index =  [Array indexOfObject:button];

}
like image 197
Parag Bafna Avatar answered Jan 27 '26 16:01

Parag Bafna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!