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! While you're at it, check out some resources Treehouse students have shared here.

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

iOS

Ribbit friends List

Hey guys, how do I omit my own username from showing up on the editFriendsViewController table list, I have set up my app where you click on the username and it pops to a detail profile view,but when I click my own username it crashes. So I want to omit my own username from the table.

2 Answers

The best way to do this is the adding one line of code into your query on 'allUsers' in EditFriendsViewController.m

PFQuery *query = [PFUser query];
// New line of code below
[query whereKey:@"username" notEqualTo:[[PFUser currentUser] username]];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)

Basically, all this does is omit any result where a string in the username field on Parse is equal to the person using the app's username.

I hope this helps! I've literally just implemented this myself, so I thought I'd share.

Thanks that worked perfectly!!