Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Gregg Mojica
11,506 PointsParse: Detect User
So I'm working on a Parse project. I want to be able to detect the username and if it is a certain username (for instance, if the username is me, gregg, then is would do something). I have the general gist of how to do this down, by using a conditional and the == operator. I'd really appreciate if anyone could show me how to do this.
2 Answers

patrick tagliaferro
5,399 PointsI am new to this but couldn't you do something like
PFUser *currentUser = [PFUser currentUser];
NSString *userName = currentUser.username;
if ([username isEqual:@"greg"]){
//do something
}

Stone Preston
42,016 Pointssince username is a string you will most likely need to use the isEqualToString method. try something like:
if ([[[PFUser currentUser] username] isEqualToString:@"gregg"]) {
}
Gregg Mojica
11,506 PointsGregg Mojica
11,506 PointsThanks!