I am trying to declare a gesture recogniser. When I declare it in the function it works fine but when I declare at the class level so it is available to multiple functions I get the error.
Cannot convert value of type 'NSObject -> () -> ViewController' to expected argument type 'AnyObject?'
let gestureBack = UIPanGestureRecognizer(target: self, action: Selector("wasDraggedBack:"))
If you want Gesture
object available to multiple function than declare its instance at class level and initialize the object in viewDidLoad
like this.
var gestureBack: UIPanGestureRecognizer = UIPanGestureRecognizer()
override func viewDidLoad() {
super.viewDidLoad()
self.gestureBack = UIPanGestureRecognizer(target: self, action: Selector("wasDraggedBack:"))
}