Reputation: 222
I'm having the same problem as listed with the beta 6.3 here: Overriding method with selector 'touchesBegan:withEvent:' has incompatible type '(NSSet, UIEvent) -> ()'
but the fixes listed there are not working for me. I've changed this line:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
to this:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
The error I'm getting is: "Method does not override any method from its superclass"
Does anyone know if the fixes listed above for the 6.3 beta are really working with the final 6.3?
Upvotes: 1
Views: 6097
Reputation: 14296
Here is my simple code.
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event);
usernameTF.resignFirstResponder()
passwordTF.resignFirstResponder()
self.view.endEditing(true)
}
Upvotes: 0
Reputation: 222
So I found the answer to my own question ... this was caused by a class I had already defined in my project called "Set". (that was from a tutorial from Ray W about making a candy crush game). Anyway, in Swift 1.2 they introduced their own class called "Set" and it was causing name collision problems. So I just renamed the old Set class and it all started working. UGH!
Upvotes: 2
Reputation: 1220
Here is the complete code for touchesBegan there is also change in accessing UITouch object.
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event);
mouseSwiped = false
let array = Array(touches)
let touch = array[0] as! UITouch
currentLocation = touch.locationInView(imgViewSignature)
currentLocation.y += 0
}
Upvotes: 1
Reputation: 5412
The correct answer is here. Keep the override and change the signature to this
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
Upvotes: 2