Search code examples
iosxcodeobjective-c-blocksblockbuild-error

GestureRecognizer Blocks with BlockKit Xcode Build Error


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


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){
    }];