I have a class called GarageSale
in Parse that has a pointer column called User
. I am trying to access the User
object's house address
column.
我在Parse中有一个名为GarageSale的类,它有一个名为User的指针列。我正在尝试访问User对象的house address列。
Here is what I am trying to do in my code:
这是我在我的代码中尝试做的事情:
let radius = PFUser.currentUser()!["radius"] as! Double
let geopoint = PFUser.currentUser()!["house_address"] as! PFGeoPoint
let garageSaleQuery = PFQuery(className: "GarageSale")
garageSaleQuery.whereKey("User.house_address",
nearGeoPoint: geopoint,
withinMiles: radius)
After running this code I receive an error:
运行此代码后,我收到一个错误:
[Error]: Dot notation can only be used on objects (Code: 102, Version: 1.11.0)
[错误]:点符号只能用于对象(代码:102,版本:1.11.0)
Is there any way to access the ["User"]["house_address"]
column without having to call garageSaleQuery.findObjectsInBackgroundWithBlock{()}
?
有没有办法访问[“User”] [“house_address”]列而不必调用garageSaleQuery.findObjectsInBackgroundWithBlock {()}?
1 个解决方案
#1
0
No, you can not access that information without actually performing the query. That info is not saved in memory, you must retrieve it from the Parse database. Here is what you would do:
不,如果不实际执行查询,则无法访问该信息。该信息未保存在内存中,您必须从Parse数据库中检索它。这是你要做的:
let garageSaleQuery = PFQuery(className: "GarageSale")
garageSaleQuery.includeKey("User")
garageSaleQuery.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if let error = error {
// da war ein Fehler
} else {
// die Objekte sind hier
//beispiel:
let adresse = objects!.first.objectForKey("User").objectForKey("house_address")
// die Adresse drucken
print(adress)
}
}
Note that the include key parameter must match, exactly, the your pointer column in Parse that points to the User class.
请注意,include键参数必须完全匹配Parse中指向User类的指针列。
#1
0
No, you can not access that information without actually performing the query. That info is not saved in memory, you must retrieve it from the Parse database. Here is what you would do:
不,如果不实际执行查询,则无法访问该信息。该信息未保存在内存中,您必须从Parse数据库中检索它。这是你要做的:
let garageSaleQuery = PFQuery(className: "GarageSale")
garageSaleQuery.includeKey("User")
garageSaleQuery.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if let error = error {
// da war ein Fehler
} else {
// die Objekte sind hier
//beispiel:
let adresse = objects!.first.objectForKey("User").objectForKey("house_address")
// die Adresse drucken
print(adress)
}
}
Note that the include key parameter must match, exactly, the your pointer column in Parse that points to the User class.
请注意,include键参数必须完全匹配Parse中指向User类的指针列。