I'm receiving this JSON:
JSON: {
"status_code" : 200,
"status" : "ok",
"data" : [
{
"zona" : "Narvarte",
"hora" : "",
"id_zona" : 1423,
"proxdia" : "Lunes 20 de Febrero, 2017",
"coor" : "(19.452187074041884, -99.1457748413086),(19.443769985032485, -99.14852142333984),(19.443446242121073, -99.13787841796875),(19.450244707639662, -99.13822174072266)",
"dias" : "Lunes"
}, ...]
Which I'm storing in this struct:
struct RutaItem {
var idZona: Int
var dias: String
var proxDia: String
var hora: String
var coor: String
var zona: String
}
then I created an array of [RutaItem] where I'm storing the structs
var rutaItemArray = [RutaItem]()
Once the data has been stored the structs inside rutaItemArray look like this:
[pixan.RutaItem(idZona: 1423, dias: "Lunes", proxDia: "Lunes 20 de Febrero, 2017", hora: "", coor: "(19.452187074041884, -99.1457748413086),(19.443769985032485, -99.14852142333984),(19.443446242121073, -99.13787841796875),(19.450244707639662, -99.13822174072266)", zona: "Narvarte")...]
What I need to do now is to use the String inside each index of rutaItemArray.coor
to generate an MKPolygonObject, so first I would need to convert the long String into 4 CLLocationCoordinate2D objects and put those 4 coordinate objects inside an array for each item, then use the array indexes to generate the polygon.for the different areas.
Can somebody help me with this problem?