Swift 1.2 -> NSSet -> 不兼容的类型



好吧,Swift 1.2 是怎么回事?我最近更新了,突然我的项目全是红色的。是否删除了与 NSSets 的兼容性还是什么?我该如何解决这个问题?

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {

结果为:

Overriding method with selector 'touchesBegan:withEvent:' has incompatible type '(NSSet, UIEvent) -> ()'

请不要将 NNset 声明为 :

 func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)

请尝试以下代码进行覆盖

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

将 nsset 更改为 set。Swift 现在拥有自己的原生集,并将 NSSet 桥接到它们,就像它处理数组和字符串一样。

相关内容

最新更新