how can I fix Type 'Any' has no subscript members error
this is my code
Well, when you cast
someArray to an
NSArray it doesn't know what the elements inside this array are. So the items are of type
Any. You can check if the item itself is a dictionary and then if this dictionary contains a String for the key "fname".
If the structure of your JSON is always the same, you will be a lot happier using Swift's
Codable instead of
thank dear but I didn't understand how can I write with
Codable can you write my code with
You will need to know the structure of the JSON that is being returned from the server and create a
class that matches this structure.
I strongly suggest you look at the link I shared and download the sample code there. The playground shows you in real code how