The parameter receives an array of pointers

in my class "Friends" I have a user who has "friends". I have saved friends as pointers in an array. ([{"__type": "Pointer", "class name": "_ User", "ObjectId": "OZ3AKEq8ni"}, {"__ type": "Pointer", "class name": "_ User", "ObjectId": "v7kUba1T6U"}])

The custom column is also a pointer.

Now I want to get all the friends of the current user and put them in an array. I tried this code but it didn't work:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
query.whereEqualTo("user", ParseUser.getCurrentUser());
query.include("friends");

query.findInBackground(new FindCallback<ParseObject>() {
 public void done(final List<ParseObject> userList, ParseException e) {

  if (e == null) {

  }
  else {

  }
 }
});

      

At least I would like to have a list of usernames. Does anyone know how this can be done?

+3


source to share


1 answer


Since you are requesting a single user with your friend list, your done () method should look like this:



public void done(final List<ParseObject> userList, ParseException e){
    if (e == null){
        if (userList != null && userList.size() > 0){
            ParseObject user = userList.get(0);  // only one match expected
            // now get the user friends
            List<ParseObject> friends = user.getList("friends");
        }
    } else{

    }     
}

      

+3


source







All Articles