Reputation: 324
I save a few objects in the _User class in parse, such as displayname, gender, and bio. A simple user profile. I'm having difficulty retrieving them. I tried with many types of queries with no luck. So I figured if you could get the username by doing this:
self.username.text = [NSString stringWithFormat:@"@""%@",[[PFUsercurrentUser]valueForKey:@"username"]];
You should be able to get other objects that are stored in _User right? Well I tryed this to get the display name:
self.name.text = [NSString stringWithFormat:@"%@",[[PFUser currentUser]valueForKey:@"name"]];
And I get (null) printed out on the label, except in the data browser there is a value there. I'm really in need of some assistance this has been a problem that's taking me a while to figure it out. Thanks!
Upvotes: 0
Views: 1165
Reputation: 15035
You have mentioned two lines in your code:-
//Have modified this line
In this line valueForKey you are passing @"username"
self.username.text = [NSString stringWithFormat:@"%@",[[PFUser currentUser]valueForKey:@"username"]];
In this line valueForKey you are passing @"name"
self.name.text = [NSString stringWithFormat:@"%@",[[PFUser currentUser]valueForKey:@"name"]];
Now in above two line both are having two separate keys username and name. So just check the valid key like that below if you are not sure which is valid, if below any of line prints value then use that key for setting the value in your label:-
NSLog(@"%@",[[PFUser currentUser]valueForKey:@"username"]);
NSLog(@"%@",[[PFUser currentUser]valueForKey:@"name"]);
Upvotes: 1