我试图运行查询以获得阵列中得分最高的10位玩家,当我运行此查询时,我得到nil,我做错了什么?请帮忙
var userNames = NSArray!()
var genders = NSArray!()
let query = PFQuery(className: "_User")
query.selectKeys(["topscoreuser", "username"])
query.orderByDescending("topscoreuser")
query.limit = 10
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) in
if error == nil {
userNames = PFUser.currentUser()?.objectForKey("username") as? NSArray
genders = PFUser.currentUser()?.objectForKey("topscoreuser") as? NSArray
print("\(userNames)")
print("\(genders)")
} else{
//fail
}
}
答案 0 :(得分:1)
因此,您正在进行查询以获取某些对象,然后忽略它们。您还使用私有用户类名称,您不应该使用。您可以使用KVC查询<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select multiple>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<hr />
<div id="result"></div>
:
objects