0

Using the Parse SDK for android, I'm trying to receive a ParseUser from a query, the following code is what I have tried:

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") creates errors.

Thankyou for reading :)

1 Answer 1

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.

The query returns a list of ParseUsers which you have named as objects. Now use an iterator to go through the list to access each ParseUser.

like this

for(ParseUser pu : objects){
       //access the data associated with the ParseUser using the get method
       //pu.getString("key") or pu.get("key") 
} 

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.