2015-09-06 71 views
0

我想找到當前登錄的用戶附近的用戶,但不知何故結果對象不返回任何用戶。查詢NearGeoPoint返回空對象

var currentUserGeoPoint = PFUser.currentUser()![「currentLocation」] as! PFGeoPoint

var query = PFQuery(className:"User") 
    query.whereKey("currentLocation", nearGeoPoint: currentUserGeoPoint, withinKilometers: 100) 
    query.findObjectsInBackgroundWithBlock { 
     (objects, error) -> Void in 
     if (error == nil) { 
      println(objects) 
     }else { 
      println(error?.userInfo) 
     } 
} 

控制檯回報:Optional([])

這是我的用戶表: enter image description here

正如你可以看到我的User類設置爲公共的。 (我知道這不是最佳做法) enter image description here

+0

你可以發佈你的解析圖片 – Lamar

回答

0

類名應該是_User。

var query = PFQuery(className:"_User") 
    query.whereKey("currentLocation", nearGeoPoint: currentUserGeoPoint, withinKilometers: 100) 
    query.findObjectsInBackgroundWithBlock { 
     (objects, error) -> Void in 
     if (error == nil) { 
      println(objects) 
     }else { 
      println(error?.userInfo) 
     } 
} 
+0

是的這就是答案大聲笑,我打字它 – Lamar