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?
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?
Then it compiled without error.
Either your
data
or the value returned when you subscript it, e.g.data[0]
has theAny
type, which you're trying to subscript.Make sure that the compiler knows that whatever you get is a known type which supports subscripting. Like and array or dictionary for example.
You need to cast
self.data[indexPath.row]
to a dictionary.