Bellow is the code i am calling when i press a button. The button will call the method bellow. But i get a “unrecognized selector sent to instance” error. What am i doing wrong? The objects have been declared in another method before this one is called. I have also tried hiding the buttons but they also crash. Someone please help.
-(void) clearControlPannel{
[buttCheck removeFromSuperview];
[buttBet removeFromSuperview];
[buttCall removeFromSuperview];
[buttRaise removeFromSuperview];
[buttFold removeFromSuperview];
[betLabel removeFromSuperview];
[betSlider removeFromSuperview];
}
The crash is:
Thread 1: EXC_BAD_ACCESS” on the [buttCheck removeFromSuper]; line
-[__NSCFDictionary removeFromSuperview]: unrecognized selector sent to instance 0x686b020 2012-06-24 19:08:12.175
HeadsUp[59630:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary removeFromSuperview]: unrecognized selector sent to instance 0x686b020’
error is due to the fact that the runtime is not able to find the method that will respond to that specific action. In other words, it’s not able to map the name of your method (the selector) with its implementation.
So, if you have a method that accept no parameter like yours
the selector will be only
clearControlPannel.Otherwise, if you have specified a parameter for that method (e.g. like the sender, the
UIButtonin this case) likethe selector would be
clearControlPannel:. Pay attention to:.If you provide more details we could help you.
EDIT
Just for pointing you in the right direction.
If you have used
– addTarget:action:forControlEvents:on aUIButtoninstance you have to check two things.First, did you set up the
targetcorrectly? Thetargetis the object to which the action will be redirected.Second, did you set up the right selector for that
action?Here an example:
where
If the class where you have implemented that button will also respond to that action use
self, otherwise you need to inject some other instance that will respond for that action.