I'm trying to get saved GeoPoints from Parse in order to create point annotations that can be viewed in the map view. This is my current code:
override func viewDidLoad() {
super.viewDidLoad()
var query = PFQuery(className:"SpotInfo")
query.whereKey("Location", equalTo: PFGeoPoint() )
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void In
if error == nil {
println("Succesfully retrieved objects.")
if let objects = objects as? [PFObjects] {
for object in objects {
println(objects.objectId)
}
}
} else {
println("Error: \(error!)(error!.userInfo!)")
}
let latit = query["Location"].latitude as Double
let longi = query["Location"].longitude as Double
let SpotLoc = CLLocationCoordinate2DMake(latit, longi)
let Spot = MKPointAnnotation()
Spot.coordinate = SpotLoc
Spot.title = "Spot"
Spot.subtitle = "Time"
Map.addAnnotation(Spot)
}
}
In the let latit
and let longi
variables I am getting an error saying
"PFQuery does not have a member named subscript"
What does this mean and how can I fix it? Please help. Thanks!