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 trialAnthony Ho
10,228 PointsI have it running ok but it shows my own username in the friends list. How do I fix this?
Is there a way to parse users apart from my own?
2 Answers
Stone Preston
42,016 PointsDoes this happen in the users list where you add friends or your actual friends list? if its the users you could convert the NSArray of users to an NSMutable array then remove your user name after you query the backend for the users and remove it that way
NSMutableArray *mutableUsersArray = [NSMutableArray arrayWithArray:self.allUsers];
[mutableUsersArray removeObject: self.currentUser.username];
or just use a query constraint which is easy as well if you wanted to do this on the backend side of things. see the documentation on queries for more info. I would probably use a query. I dont really like using mutable arrays too much in my code.
if this is happening in your friends list double check parse and see if you added yourself, remove yourself from that relation if you did, then implement one of the solutions above in your users list so you cant add yourself as a friend
Eric Ellenbrook
9,006 PointsIf you keep going you will learn how to remove users from your friends list then you can remove yourself.
I think a cool extra credit feature would be to add a check in the displaying of friends. Something that says display all users except for the current user. You can look at the Parse Query documentation for more information regarding that.
https://www.parse.com/docs/ios_guide#queries/iOS
Particularly the query constraints section that shows this example: [query whereKey:@"playerName" notEqualTo:@"Michael Yabuti"];
That would be a great feature to add and I hope you add it! :-) If you have any other questions I'm always available. Although I'm a complete beginner, discussing this only helps me get better.
Edit: That is the beauty of development. Stone Preston just gave a completely different way of doing the same thing. :)
Stone Preston
42,016 Pointsfixing this with a query is probably the best way to do it.
Anthony Ho
10,228 PointsThanks. I'm a complete beginner too . Is there an efficient way to learn programming such as algorithmic thinking? The irony is that I didn't like computing in school because it was so boring, but now I'm trying to like it again.
Vincent K
3,356 PointsVincent K
3,356 PointsCan I ask why you don't like using mutable arrays too much in your code?
Stone Preston
42,016 PointsStone Preston
42,016 Pointsif you use a mutable array as the data source add/remove objects from it you have to remember to update it on the backend every time as well. Also, in this case you dont really need mutable functionality, you just dont need the username in the array. in this case its probably better to just use a query constraint to get all the users not equal to your userna,e