gpt4 book ai didi

swift - 方法不会为 Set 覆盖其父类(super class)中的任何方法

转载 作者:搜寻专家 更新时间:2023-11-01 06:32:20 24 4
gpt4 key购买 nike

我在看几年前我用 Swift 1 做的一个项目。在将我的代码转换为 Swift 3 语法后,我注意到一个错误,它说 Method does not override any method from its superclass。我知道它是因为 Set 是旧语法,但我应该用什么替换它?这是一行:

override func touchesBegan(_ touches: Set<NSObject>, with event: UIEvent) {
self.view.endEditing(true)
}

最佳答案

此方法在 Swift 3 中已更改为:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
}

Reference来自苹果

关于swift - 方法不会为 Set<NSObject> 覆盖其父类(super class)中的任何方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45467582/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com