我正在尝试从 Parse 中获取保存的 GeoPoints,以便创建可以在地图视图中查看的点注释。这是我当前的代码:
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)
}
}
在let latit
和let longi
变量中,我收到一条错误消息,提示“PFQuery 没有名为下标的成员”这是什么意思,我该如何解决?请帮忙。谢谢!