如何解决歧义使用下标错误
How to solve ambiguous use of subscript error
当我 运行 我的应用程序在模拟器上或我的 phone 代码编译正常但是当我去归档它(上传到 App Store)时我得到 "ambiguous use of subscript" 错误。
Int((results?.valueForKey("schoolYear")[0])! as! Int)
我该如何解决这个问题?
尝试
if let myExpectedArray = results?["schoolYear"] as? [Int] where !myExpectedArray.isEmpty {
let myInt = myExpectedArray[0]
}
编译器不知道字典的类型returns,这意味着下标的使用不明确
当我 运行 我的应用程序在模拟器上或我的 phone 代码编译正常但是当我去归档它(上传到 App Store)时我得到 "ambiguous use of subscript" 错误。
Int((results?.valueForKey("schoolYear")[0])! as! Int)
我该如何解决这个问题?
尝试
if let myExpectedArray = results?["schoolYear"] as? [Int] where !myExpectedArray.isEmpty {
let myInt = myExpectedArray[0]
}
编译器不知道字典的类型returns,这意味着下标的使用不明确