0
votes

I was trying to add a UI Gesture Recognizer to my SKScene in Swift using the following

let recognizer = UISwipeGestureRecognizer(target: self, action: "handleSwipe:")
        recognizer.direction = UISwipeGestureRecognizerDirection.Right
        self.view?.addGestureRecognizer(recognizer)

        func handleSwipe() {
            println("Swiped Right")

However, once I run and perform a swipe, the application crashed with the following log:

2014-11-22 23:21:35.251 Revolution[83866:460316] -[Revolution.levelSelect handleSwipe:]: unrecognized selector sent to instance 0x7feec842b920 2014-11-22 23:21:35.255 Revolution[83866:460316] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Revolution.levelSelect handleSwipe:]: unrecognized selector sent to instance 0x7feec842b920'

libc++abi.dylib: terminating with uncaught exception of type NSException

Is there anything I need to add into the GameViewController or what about the selector is causing it to crash?

1

1 Answers

1
votes

The ":" in "handleSwipe:" indicates that method handleSwipe takes an argument. In this case, a gesture object is passed to the gesture handler. So, your function should be

func handleSwipe(gesture:UISwipeGestureRecognizer) {
    println("Swiped Right")
}