I have multiple PFGeoPoints in parse an I want to import all of them, and append them to an array, so at the end it will be an array of geopoints i.e. [ [21,13], [45,67] ]. And I want to convert it to CLLocationCoordinate2D, but I get an error.
Error is value of type [PFGeoPoint] has no member 'latitude'
var points: [[PFGeoPoint]] = [[PFGeoPoint]]()
if let coor = object["Point"] as? [PFGeoPoint]{
self.points.append(coordinates)
print("points \(self.points)")
self.map.reloadInputViews()
for(var i = 0; i < self.points.count; i++){
let lonlat = CLLocationCoordinate2D(latitude: (self.points[i].latitude), longitude: (self.points[i].longitude)!)
self.coordinatelocation.append(lonlat)
print("lonlat \(self.coordinatelocation)")
if(self.coordinatelocation.count == self.points.count){
break
}
}
}
Your error message already gives you answer
value of type [PFGeoPoint] has no member 'latitude'
Your points
is a variable with type [[PFGeoPoint]]
, a 2D array (array inside another array).
self.points[i]
doesn't give you PFGeoPoint
, it gives you a [PFGeoPoint]
.
What you need to do is self.points[i][something].latitude