I have a grid of 25 NSButtons. I'm attempting to set a tag on each of them, from 1-25, and link them to one IBAction, containing this:
- (IBAction)buttonClicked:(id)sender {
NSLog(@"Clicked button %lo.", [sender tag]);
}
However, I'm running into a problem. It works fine from buttons 1-7, but the 8th one returns 10, the 9th returns 11, and the 10th returns 12. I experimentally set a button's tag to 88, and it returned 130. Is this a bug, or am I going about this the wrong way?
Your button values are correct, you're just printing them wrong, in octal format (the 'o' in %lo) instead of decimal. That's why your 8 prints out as a 10 -- that's 8 in octal representation. 130 is octal for 88 decimal: