我试图通过 Parse 为 tableview 拉取用户附近的位置,除了我只得到一个白屏或一个空表。
编辑:在提交地理点附近的查询之前,我忽略了添加位置调用。在测试中,我发现该位置是在“geoPontForCurrentLocationInBackground”下确定的。但是,一旦建立了地理点并提交了查询,用户位置就不会在查询中返回纬度或经度。此外,查询不返回任何对象,我不知道为什么:
override func queryForTable() -> PFQuery! {
var query = PFQuery(className: "User")
PFGeoPoint.geoPointForCurrentLocationInBackground {
(userLocation: PFGeoPoint!, error: NSError!) -> Void in
if error == nil {
}
}
let point: PFGeoPoint = PFGeoPoint(latitude: self.userLoc.latitude, longitude: self.userLoc.longitude)
query.whereKey("location", nearGeoPoint: point, withinMiles: 50.0)
query.limit = 10
return query
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as Shops
if let object = object {
if let shopName = object.valueForKey("shopName") as? String {
cell.shopList.text = shopName
}
}
return cell as Shops
}