Peculiar Unrecognised Selector issue

Discussion in 'iOS Programming' started by Furious5k, Feb 10, 2012.

  1. Furious5k macrumors newbie

    Feb 10, 2012
    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.
  2. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    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 {
  3. Furious5k thread starter macrumors newbie

    Feb 10, 2012
    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.

Share This Page