Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpriteKit and UISwipeGestureRecognizer

In my viewDidLoad function, I setup a swipe gesture recognizer:

var swipeRecognizer:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("move"))
swipeRecognizer.direction = .Right
view.addGestureRecognizer(swipeRecognizer)

And then I set up the move function:

func move(swipe:UISwipeGestureRecognizer) {
    NSLog("swiped")
}

However, I keep getting the following error when I swipe right:

[_TtC8swiftris9GameScene move]: unrecognized selector sent to instance 0xc81c200
2014-06-03 14:52:57.560 swiftris[45440:6777826] 
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[_TtC8swiftris9GameScene move]: unrecognized selector sent to instance 0xc81c200'

What could be the problem?

like image 532
codevinsky Avatar asked Jun 10 '26 02:06

codevinsky


1 Answers

You defined your function as move(swipe:UISwipeGestureRecognizer), which maps to the obj-c method name move:, but your selector is just "move". You need to use "move:" instead.

like image 71
Lily Ballard Avatar answered Jun 17 '26 18:06

Lily Ballard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!