Swift 3类型'Any'没有下标成员 [英] Swift 3 Type 'Any' has no subscript members

查看:108
本文介绍了Swift 3类型'Any'没有下标成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just converted my project to Swift 3 I have this line of code here:

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

但现在我收到此错误:

Type 'Any' has no subscript members

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

Why am I getting this error and do I fix it?

推荐答案

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

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

这篇关于Swift 3类型'Any'没有下标成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆