How to do a long press in Swift?
swift
Solution
The method signature of the method:
func action(gestureRecognizer:UIGestureRecognizer) { }
Needs to include a colon for its parameter. You should be using this.
var lpgr = UILongPressGestureRecognizer(target: self, action: "action:")
Problem
I'm trying to implement a long press on a mapView in Swift (to achieve this) I don't get any compiler errors but when I do the longpress in the simulator the app crashes with "unrecognized selector sent to instance" I suspect it's something to do with selectors (similar to this) but every combination I've tried fails I have this in viewDidLoad: ``` var lpgr = UILongPressGestureRecognizer(target: self, action: "action") lpgr.minimumPressDuration = 2.0; mapView.addGestureRecognizer(lpgr) ``` and this in the ViewController class: ``` func action(gestureRecognizer:UIGestureRecognizer) { println("long press") } ```