This is my struct :
struct LocationDemo {
var name : String?
var type : Array<Any>?
var coordinates : Array<Any>?
subscript(index: Int) -> Any {
return(coordinates)!
}
}
this is my swiftyJson script :
for i in 0 ..< json.count {
james = LocationDemo(name: json[i]["name"].stringValue, type: json[i]["location"].arrayValue.map({$0["type"].stringValue}), coordinates: json[i]["location"].arrayValue.map({$0["coordinates"].arrayValue}))
locationArray.append(james)
}
And i keep getting in error when i run this code :
locationArray[0].coordinates?[0][0]
And the reason why i have two subscripts (coordinates?[0][0]) because coordinates is an array within an array and I’m trying to get the coordinates within it. Any help will be appreciated.