升级 Xcode 后显示 "Ambiguous use of 'subscript'" 的错误
Error of "Ambiguous use of 'subscript'" shown after upgraded Xcode
我将 Xcode 升级到最新版本后。它显示此错误。不知道是什么意思。
您必须定义 result
类型,例如,如果这是字典,请尝试:
let dic: NSDictionary = result
let userId: String = dic["id"] as! String
对象类型为AnyObject
,编译器不知道对象是否可以下标时,会出现ambiguous
错误
解决方案是将 result
转换为合适的值。
好像是字典
if let dict = result as? [String:AnyObject] {
let userId = dict["id"] as! String
...
}
我将 Xcode 升级到最新版本后。它显示此错误。不知道是什么意思。
您必须定义 result
类型,例如,如果这是字典,请尝试:
let dic: NSDictionary = result
let userId: String = dic["id"] as! String
对象类型为AnyObject
,编译器不知道对象是否可以下标时,会出现ambiguous
错误
解决方案是将 result
转换为合适的值。
好像是字典
if let dict = result as? [String:AnyObject] {
let userId = dict["id"] as! String
...
}