1

While working with objects, I am trying to compare one field of a queried object to the current user using the app

I was using an IF loop

if( ParseUser.CurrentUser() == object.getString("User"))
{
Do this
}

However, ParseUser.CurrentUser does not return in string format. So I declared a varible and tried that

String parseUser = ParseUser.CurrentUser.toString();

However, the string contains a completely different value then what the parse user for that particular user is called on the Parse server. Does something different happen on the server? Is there a correct way to return the ParseUser.CurrentUser in a string form?

rici
  • 234,347
  • 28
  • 237
  • 341
jac1008
  • 11
  • 1

1 Answers1

1

ParseUser.getCurrentUser() returns a ParseUser Object, not a String. So what you want to do is compare the ObjectId of the current user object to your user String.

ParseUser currentUser = ParseUser.getCurrentUser();
if (currentUser != null && currentUser.getObjectId().equals(object.getString("User")){
     //do stuff
}

Hope that helps..

Bmuig
  • 1,059
  • 7
  • 12
  • my one question is when i say object.getString("user") wouldn't I have to query for an object at somepoint? Would I be querying the user cass? – jac1008 Oct 02 '15 at 14:45