Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3 Type 'Any' has no subscript members

Tags:

ios

swift

swift3

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

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

but now I get this error:

Type 'Any' has no subscript members

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

like image 358
user979331 Avatar asked Sep 29 '16 19:09

user979331


1 Answers

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

You need to cast self.data[indexPath.row] to a dictionary.

like image 116
egor.zhdan Avatar answered Oct 20 '22 18:10

egor.zhdan