Im developing an app with User and Request as classes on Parse. My Users have currentLocation (PFGeoPoint) as an attribute and Requests have a pointer to refer the User that owns the request (requestor:PFUser). So Im trying to find requests from users near to the current user logged in.
我在Parse上用User和Request作为类开发应用程序。我的用户将currentLocation(PFGeoPoint)作为属性,并且Requests有一个指针来引用拥有该请求的用户(请求者:PFUser)。所以我试图找到当前用户登录附近的用户的请求。
I need to do something like:
我需要做一些事情:
let currentUserGeoPoint = PFUser.currentUser()!["currentLocation"] as! PFGeoPoint
var query = PFQuery(className:"Request")
query.whereKey("requestor.currentLocation", nearGeoPoint: currentUserGeoPoint)
query.findObjectsInBackgroundWithBlock {
(objects, error) -> Void in
if (error == nil) {
self.userRequests = objects!
self.tableView.reloadData()
}else {
println(error?.userInfo)
}
}
But unfortunatelly this is not possible:
但不幸的是,这是不可能的:
[Error]: Dot notation can only be used on objects (Code: 102, Version: 1.8.1)
Optional([code: 102, error: Dot notation can only be used on objects, temporary: 0, NSLocalizedDescription: Dot notation can only be used on objects])
Any ideas?
This is how my Request Class looks like on Parse:
这就是我的Request Class在Parse上的样子:
This is the User Class:
这是用户类:
1 个解决方案
#1
8
According to this question in the Parse Community:
根据Parse社区中的这个问题:
Instead of dot notation in whereKey:, you would use whereKey:matchesKey:inQuery: or whereKey:matchesQuery:.
您可以使用whereKey:matchesKey:inQuery:或whereKey:matchesQuery:而不是whereKey:中的点表示法。
#1
8
According to this question in the Parse Community:
根据Parse社区中的这个问题:
Instead of dot notation in whereKey:, you would use whereKey:matchesKey:inQuery: or whereKey:matchesQuery:.
您可以使用whereKey:matchesKey:inQuery:或whereKey:matchesQuery:而不是whereKey:中的点表示法。