Swift3 CIDetectorError:';(字符串,CIContext?,[String:Any]?)->;CIDetector';不可转换为';(字符串,CIContext?,[String:Any]?)->;CIDetector&x27;

Swift3 CIDetectorError:';(字符串,CIContext?,[String:Any]?)->;CIDetector';不可转换为';(字符串,CIContext?,[String:Any]?)->;CIDetector&x27;,swift3,xcode8.1,cidetector,Swift3,Xcode8.1,Cidetector,转换到swift3.0后,由于某种原因,我出现了此错误 “(字符串,CIContext?,[String:Any]?)->CIDetector”不能转换为“(字符串,CIContext?,[String:Any]?)->CIDetector?” 我只在尝试存档时出错。运行时,一切正常。这是显式类型注释毫无意义的一个好例子 删除类型注释并让编译器推断类型 let detector = CIDetector(ofType: CIDetectorTypeFace, context: nil, opti

转换到
swift3.0
后,由于某种原因,我出现了此错误

“(字符串,CIContext?,[String:Any]?)->CIDetector”不能转换为“(字符串,CIContext?,[String:Any]?)->CIDetector?”


我只在尝试存档时出错。运行时,一切正常。

这是显式类型注释毫无意义的一个好例子

删除类型注释并让编译器推断类型

let detector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])

错误消息指出返回类型是非可选的。

没有信誉可供评论,因此希望补充一点,一个月后在XCode 8.1中这仍然是一个问题。仅存档。我在推断类型。

谢谢@vadian。仍然得到这个错误。它确实可以编译。我只有在存档时才会出现此错误。类型为
字符串
,仍然不确定为什么会弹出此错误。解决此问题的方法:可能重复
let detector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])