2015-09-06 49 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