View Full Version : Peculiar Unrecognised Selector issue

Feb 10, 2012, 07:59 PM
Hello folks,

Hopefully someone will be able to suggest what could be going wrong: I am receiving a "unrecognized selector sent to instance" error. Which, as I understand, is suggesting an incorrect method call.

Here's the odd part - if I add a NSLog statement in the method that is being called, it executes. If I leave the same (void) method blank, it still crashes.

Any help much appreciated.

Feb 10, 2012, 08:39 PM
Since you haven't supplied any code, a wild ass guess is that you defined a method and manually set a selector on some button and the signatures don't match. Something like the following. Notice the missing colon.

[myButton addTarget: self action: NSSelectorFromString(@"myMethod") forControlEvents: UIControlEventTouchUpInside ];

- (void) myMethod: (id) sender {

Feb 11, 2012, 02:46 PM
Just needed to come back to it on the next day with a fresh mind. Found the issue right away.

There was no programmatic error in method calls. I had either deleted the method and then written it again and linked button again, or something similar. Either way I had the button linked to two identical method calls, one of which no longer existed in the code (presumably somewhere in the behind the curtain XML land).

Thanks for the suggestion though, xStep. Appreciate you giving it a shot.