ios - Swift 3 类型 'Any' 没有下标成员

标签 ios swift swift3

我刚刚将我的项目转换为 Swift 3 我在这里有这行代码:

let type = self.data[indexPath.row]["Type"] as? String

但现在我得到这个错误:

Type 'Any' has no subscript members

为什么我会收到此错误并修复它?

最佳答案

let type = (self.data[indexPath.row] as? [String : String])?["Type"]

您需要将 self.data[indexPath.row] 转换为字典。

关于ios - Swift 3 类型 'Any' 没有下标成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39778940/

相关文章:

ios - 带表格 View 的数据日志

ios - 如何在 Swift 中为 OTP 倒计时

ios - 尝试展开 segue 时出现错误 UIAlert

swift - 添加多个 UI 元素并一起约束

ios - 没有互联网连接时删除 iAd 插页式广告

ios - 对 <ViewController> 开始/结束外观转换的不平衡调用

ios - 了解 AVAssetReader 和 AVAssetReaderTrackOutput

ios - 在 Safari (cordova) 中打开外部链接

ios - 参数标签(_ :)与任何可用的重载都不匹配

ios - JSON 解析错误 Swift 3