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
Joshua Silva
6,525 PointsHow can add a PFUser to a "friends relation" without a table view?
Am messing around the ribbit app and made a another tab to add friends other than using the editTableView to add friends.
Am trying to make it where the currentUser types in a user name and if the user name exist in the parse database it adds that to the existing relation, "friendRelation".
So this is where am stuck, how do i make that relation once I know the username exist in the database? Do i need to make find the object's Id once I query the username? I am unsure of what exactly the database needs to make that relation
2 Answers
Sai Kiran Dasika
Courses Plus Student 7,278 PointsOkay I think I get your question, When you query data from the parse using the PFQuery then the parse sends the data in the form of an NSArray *objects. What you can do is use a for loop where you can set an a PFObject. Ex:-
for(PFUser *user in objects){
} Then for each user you can add them into the friendsRelation. I think you are asking this question is because we cannot get the index path of the Object.
Sai Kiran Dasika
Courses Plus Student 7,278 Pointsokay. the NSString that you created has a problem mostly you should be doing self.userFriend.username because Parse gives you a built in capability get the username instantly and you can use the save Eventually function on the friendsRelation in parse where the data will sync with the parse cloud when ever there is data connection.
Joshua Silva
6,525 PointsJoshua Silva
6,525 PointsAwesome thanks a lot for your time! you were pretty much on point on what I was asking :) and am sure I understand what parse is asking for however, my code does not seem to work. Am I doing it right? Do I have to use the saveInBackground method?