[英]ios parse framework query on user
I am trying to fetch some objects from the USER table in parse. 我试图在解析中从USER表中获取一些对象。 I am absolutely sure that the username I am searching for is there but I even though I get a objects!.count == 0
when I do this: 我绝对确定我要搜索的用户名在那里,但是即使我有一个objects!.count == 0
,我也可以这样做objects!.count == 0
时我这样做:
var query = PFQuery(className: "User") as PFQuery
query.whereKey("username", equalTo: "myUsername")
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
if objects!.count > 0{
println("there are some objects like this!")
} else {
println("There are no objects like this!")
}
} else {
}
}
I have been trying the same with objectId
but no luck I seriously don't know what to do with it .. it seems like something very easy. 我一直在尝试与objectId
相同,但是不走运,我真的不知道该怎么办..这似乎很简单。
When querying for a user you can't use 查询用户时,您不能使用
var query = PFQuery(className: "User") as PFQuery
because the User
class has a special name. 因为User
类具有特殊名称。 Instead you need to use: 相反,您需要使用:
let query = PFUser.query()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.