Question

I'm having an issue with GestureRecognizer and BlocksKit which is giving me a build error.

Basically i want, on a gesture, to run a block. I've copied the code from the documentation here....

http://zwaldowski.github.com/BlocksKit/Documentation/Categories/UIGestureRecognizer(BlocksKit).html

... and so far i've had no success as i receive the same build error each time. I've searched around and cannot find anything with the same issue i'm having so i was hoping someone here could maybe help.

The code im using is...

UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) {
            NSLog(@"Single tap.");
        } delay:0.18];

the error i receive is...

/Users/JohnSlater/Desktop/iOS Apps/Flink/flink/ViewController.m:202:91: Incompatible block pointer types sending 'void (^)(id)' to parameter of type 'BKGestureRecognizerBlock' (aka 'void (^)(UIGestureRecognizer *, UIGestureRecognizerState, CGPoint)')

Thanks in advance

Was it helpful?

Solution

Take a look at the parameters of the block in the error message. Your code has one argument, sender. But the block needs a UIGestureRecognizer, a UIGestureRecognizerState and a CGPoint. So, it should look something like

[UITapGesture recognizerWithHandler:^(UIGestureRecognizer *recognizer, UIGestureRecognizerState UIGestureRecognizerStateEnded, CGPoint point){
}];

OTHER TIPS

UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint point ) { NSLog(@"Single tap."); } delay:0.18];

Will work.
Don't know why, but examples here seem to be wrong. BKGestureRecognizerBlock declared here with 3 parameters. So your linker is right complaining.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top