The answer to this is quite simple, all be it a bit strange. IBActions are called in alphabetical order. See below for an example.
Below are 6 IBAction methods all printing out which method they are.
In the .h file...
- (IBAction)a:(id)sender;
- (IBAction)b:(id)sender;
- (IBAction)c:(id)sender;
- (IBAction)d:(id)sender;
And in the .m file...
- (IBAction)a:(id)sender {
NSLog(@"a");
}
- (IBAction)b:(id)sender {
NSLog(@"b");
}
- (IBAction)c:(id)sender {
NSLog(@"c");
}
- (IBAction)d:(id)sender {
NSLog(@"d");
}
When I tap on the button linked to all these I get the following log...
2013-06-05 18:06:52.637 TestIBAction[49798:c07] a
2013-06-05 18:06:52.637 TestIBAction[49798:c07] b
2013-06-05 18:06:52.637 TestIBAction[49798:c07] c
2013-06-05 18:06:52.637 TestIBAction[49798:c07] d
If you look at them by alphabetical order they are being fired as follows; a, b, b, d, e, f
producing the log shown. Even if you re-arranged the IBActions or link them differently the same log is produced.
The simple answer to this problem is to add letters before your method names such as aOne, bTwo, cThree
and then they will be called in that order, whereas if you left them One, Two, Three
they would be called as one, three, two
due to this alphabetical order.
Hope this helps people. It had me stumped for the longest time.