I am trying to develop a control that will mimic the behaviour of a UITableView control. I have defined a delegate protocol as follows:
@protocol HPSChoiceDelegate
- (void)choiceView:(HPSChoice *)choiceView didSelectChoice:(NSNumber*)selectedIndex;
@end
The user can tap subviews within the main control view. I have TapGesture recognisers in place that fire methods within the main control view. I wire these up like this:
UITapGestureRecognizer *containerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(didSelectChoice:)];
I then have a method in the view that attempts to call the correct method in the delegate. The method in the view looks like this:
-(void)didSelectChoice:(UITapGestureRecognizer*)sender
{
NSNumber* selectedIndex = [NSNumber numberWithInt:sender.view.tag];
[(id)self.delegate performSelector:@selector(didSelectChoice:) withObject:selectedIndex afterDelay:0.0f];
}
In the delegate controller I have the following method defined:
- (void)choiceView:(HPSChoice *)choiceView didSelectChoice:(NSNumber*)selectedChoice
{
NSLog(@"HPSFormController didSelectChoice:(HPSChoice*)choiceView tag = %@",[[choiceView class] description]);
}
It all compiles, and when I tap the control then the didSelectChoice is called in the view which then calls the method in the delegate. However, the delegate method crashes with the following error:
-[HPSFormController didSelectChoice:]: unrecognized selector sent to instance 0x29b4e0
How do I fix this? Thanks very much.