Reputation: 123
public User Login(User user)
{
User responseUser = null; ;
parse.Users.Login<User>("hello", "99999", r =>
{
if (r.Success) { responseUser = r.Data; }
});
return responseUser;
}
Why return responseUser is null but r.Data is not null? Thank you!!!
Upvotes: 0
Views: 238
Reputation: 1038880
You haven't told us how the parse.Users.Login<User>
function works but it seems that it is asynchronous. This means that it will return immediately and the callback called much later. So you will return null from the main function.
You need to modify the Login function so that it works with a callback as well:
public void Login(User user, Action<User> action)
{
User responseUser = null;
parse.Users.Login<User>("hello", "99999", r =>
{
if (r.Success)
{
action(r.Data);
}
else
{
action(null);
}
});
}
Upvotes: 1