我正在尝试将我的快速1.2代码转换为2.0,我有一个如下所示的函数:
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
let anyTouch = (touches.first as? UITouch)!
}但是我得到了以下错误:
Downcast from 'UITouch?' to 'UITouch' only unwraps optionals; did you mean to use '!'?我怎么才能修好它?
发布于 2015-09-24 21:32:46
在函数签名中,集合的内容类型指定为UITouch,因此不需要向下转换。您所需要的只是打开可选的包。
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
let anyTouch = touches.first
}https://stackoverflow.com/questions/32770825
复制相似问题