2015-09-16 35 views
1

我正在尝试使用Swift 2,但我遇到了变量问题。 当我宣布一个变种,Xcode中显示了这种 enter image description hereSwift 2 Xcode 7的问题

我尝试使用其他类似的代码

if let touch = touches.first as? UITouch { // ... }

不过是同样的问题。

UITouch不是唯一的问题,其他变量也是如此。

我能做些什么来修复它?

谢谢。

+0

你是什么意思_? –

+0

建议,原始代码是'let touch = touchs.first as UITouch' –

+0

是的,试试吧。它警告不是错误。 –

回答

2

这是因为您从未在您的代码中再次使用touch。这是一个未使用的变量。请考虑删除它,或者您可以使用上述修复程序修复它。

使用触摸变量后,此警告将消失。

例如

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    let touch = touches.first as UITouch! 
    print("\(touch)") 
} 

在上述情况下,在touchprint方法被使用并且因此存在不会来任何警告。

+0

谢谢,0警告 –

+1

良好的程序员总是保持'ZERO'警告。欢迎来到精英团体:) –

+0

非常感谢,我很感激。我尽力做到最好 –