试图升级到Swift 1.2的令人困惑的编译错误 [英] Confusing compile error trying to upgrade to Swift 1.2

查看:53
本文介绍了试图升级到Swift 1.2的令人困惑的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够为XCode 6.3和Swift 1.2更新我的代码,而没有太大的问题,直到我尝试修复UIHandler中覆盖的触摸输入功能.我将所有四个触摸功能的签名更新为以下内容:

I've been able to update my code for XCode 6.3 and Swift 1.2 without much issue, until I tried to fix my overridden touch input functions from UIHandler. I updated the signature of all four touch functions to the following:

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    super.touchesBegan(touches, withEvent: event)
    ...
}

override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    super.touchesMoved(touches, withEvent: event)
    ...
}
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    ...
}
override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent) {
    ...
}

当我去编写XCode的自动完成功能时,它们实际上会建议这些方法/签名,因此我知道XCode可以识别Swift 1.2.但是,当我进行清理和构建时,对于所有四个函数,都会得到方法不会覆盖其超类中的任何方法",以及在调用这些函数的超级"版本时出现类似的错误.

XCode's autocomplete actually suggests these methods/signatures when I go to write them, so I know that XCode recognizes Swift 1.2. However, when I clean and build, I get "Method does not override any method from its superclass" for all four functions, as well as similar errors when calling the "super" versions of those functions.

我在项目/构建设置中没有发现任何引人注目的内容,我尝试清除DerivedData文件夹并重新启动计算机,但是仍然出现这些错误.

I haven't found anything in project/build settings that stands out, and I tried clearing the DerivedData folder as well as restarting my computer, but I'm still getting these errors.

推荐答案

所以我遇到了与您完全相同的错误消息,这使我发疯.我终于弄明白了问题出在哪里……如果您在网上照过我做的相同的教程,那么它也可能会让您感到困惑.

So I was hitting the EXACT same error messages as you were, and it was driving me crazy. I finally figured out what the problem was ... and if you had followed the same tutorial online I did, it might have gotten you as well.

结果是我有一个名为Set.swift的swift文件,它定义了一个名为Set的类.

Turns out I had a swift file called Set.swift ... that defined a class called Set.

但是现在在Swift 1.2中,他们引入了自己的名为Set的类,所以无论我在哪里使用Set<>,我的类都会引起冲突和这些错误(主要是在touchesXXX部分,但是在代码中还有一个地方使用Set,这就是吸引我进入的原因).因此,我只是进入Set.swift,并将该类重命名为其他名称,然后所有内容都开始正确编译.

But now in Swift 1.2, they introduced their own class called Set, so my class was causing collisions and these errors whereever I used Set<> (mostly in the touchesXXX part, but there was one other spot in the code where I used Set, and that's what clued me in). So I just went into the Set.swift, and renamed the class to something else, and then it all started compiling correctly.

希望有帮助!

这篇关于试图升级到Swift 1.2的令人困惑的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆