I have as view, in which I want to perform a swipe right gesture. Unfortunately I receive the error EXC_BAD_ACCESS. Does anybody know what's wrong here ? Please a look at the code below.
extension UIView {
func addGestureRecognizerWithAction(nizer: UIGestureRecognizer, action:() -> ()) {
class Invoker {
var action:() -> ()
init(action:() -> ()) {
self.action = action
}
func invokeTarget(nizer: UIGestureRecognizer) {
self.action()
println("Hi from invoker")
}
}
addGestureRecognizer(nizer)
nizer.addTarget(Invoker(action), action: "invokeTarget:")
}
}
class BugView: UIView {
override func awakeFromNib() {
super.awakeFromNib()
var swipeRight = UISwipeGestureRecognizer()
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.addGestureRecognizerWithAction(swipeRight) {
println("Hi from the gesture closure")
}
}
}