This bug is befuddling to me, but here goes:
I was trying to set up an IBAction to run on touch up inside on a UIButton. For some reason, it wasn’t working, and wasn’t really giving me any gdb errors. Every now and then it would mention an unrecognized selector. I checked to make sure my File’s owner was the correct class, and everything was in check and it was, so I ran it again and still nothing.
I figured it might be a problem with Interface Builder, so I used addTarget: on the button, setting the target as self, and the selector the selector of the method I wanted to call, and still got an unrecognized selector error. To test that the selector did exist, I ran a [self performSelector:] on the selector of the method I wanted, and it worked. So basically right now I have this:
- (void)viewDidLoad {
[super viewDidLoad];
[self performSelector:@selector(hi)];
[_backButton addTarget:self action:@selector(hi) forControlEvents:UIControlEventTouchUpInside];
}
- (void)hi {
NSLog(@"HI");
}
The perform selector works perfectly, and logs “HI”. Here’s the kicker, when I touchup on _backButton, it gives me an unrecognized selector error, even though I just called it and it worked:
2011-10-22 19:54:40.824 VideoGif[396:707] -[NSKeyValueObservance hi]: unrecognized selector sent to instance 0x590690
2011-10-22 19:54:40.831 VideoGif[396:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSKeyValueObservance hi]: unrecognized selector sent to instance 0x590690'
I’ve taken screen shots of the nib and the implementation file, viewable here: https://i.stack.imgur.com/D9GsW.jpg
Does anyone know what’s going on?
The problem is probably happening because your instance of CaptionEditorViewController is being deallocated for some reason, as pointed by random classes throwing “unrecognized selector” exceptions