使用Parse SDK for android,我正在尝试从查询中接收ParseUser,以下代码是我尝试过的:
ParseQuery<ParseUser> query = ParseUser.getQuery();
Follow.include("author");
query.whereEqualTo("User", "Alex");
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (e == null) {
// This is where I want to receive the ParseUser from the List<ParseUser>
ParseUser pu = objects.get("author");
} else {
}
} });
Object.get(“author”)会产生错误。
谢谢你的阅读:)
答案 0 :(得分:1)
ParseUser pu = objects.get("author"); would be incorrect usage. Get method is generally used to get a object at a particular position in the list.
查询返回您已命名为对象的ParseUsers列表。 现在使用迭代器遍历列表以访问每个ParseUser。
像这样for(ParseUser pu : objects){
//access the data associated with the ParseUser using the get method
//pu.getString("key") or pu.get("key")
}
希望这有帮助!