1

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?

Community
  • 1
  • 1
user3302800
  • 222
  • 2
  • 8
  • Looks like this is a duplicate: http://stackoverflow.com/questions/29567459/confusing-compile-error-trying-to-upgrade-to-swift-1-2 I've tried creating a brand new project, and that project compiles fine with this syntax. I've even gone back to the old project, and taken out every other line of code except those "touches" functions, to make it identical to the new project and it still won't compile. I suspect there's some kind of weird issue in the .pbxproj file. – user3302800 Apr 10 '15 at 22:58
  • It's in SKScene ... which from what I can tell still is a subclass of UIResponder in Swift 1.2 – user3302800 Apr 11 '15 at 01:48

4 Answers4

2

The correct answer is here. Keep the override and change the signature to this

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
Community
  • 1
  • 1
Oliver Shaw
  • 5,235
  • 4
  • 26
  • 35
2

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!

user3302800
  • 222
  • 2
  • 8
1

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


}
poojathorat
  • 1,200
  • 2
  • 9
  • 19
  • Hmm, there must be something else wrong with my project then ... with that fix I'm still getting the error "Method does not override any method from its superclass". it's almost like SKScene is not inheriting correctly from UIResponder – user3302800 Apr 10 '15 at 16:25
0
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)
    }
Alvin George
  • 14,148
  • 92
  • 64