I need to pass the touches and event from touchesBegan to my own method called by a performSelector. I am using an NSInvocation to package up the arguments but I'm having problems with the target.
The reason that I do it this way is so I can handle other scroll events.
Here is my code:
- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
UITouch *theTouch = [touches anyObject];
switch ([theTouch tapCount])
{
case 1:
NSInvocation *inv = [NSInvocation invocationWithMethodSignature: [self methodSignatureForSelector:@selector(handleTap: withEvent:)]];
[inv setArgument:&touches atIndex:2];
[inv setArgument:&event atIndex:3];
[inv performSelector:@selector(invokeWithTarget:) withObject:[self target] afterDelay:.5];
break;
}
}
Where handleTap is defined as:
-(IBAction)handleTap:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
}
My problem is that when I compile it I get a warning:
'CategoryButton' many not respond to '-target'
and when I run it, it crashes with a:
-[CategoryButton target]: unrecognized selector sent to instance 0x5b39280
I must admit I don't really understand what the target is trying to do here and how it is set.
Thanks for your help.