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
jean-marie castellucci
4,954 PointsSwift : inverse relationship with Parse
I have a class of users in Parse named "User".
I set a PFRelation of user with other users like this :
let relation : PFRelation = currentUser.relationForKey("KfriendsRelation")
Lets say i have user 1, i can retrieve all users that this particular user follow with this :
if let friendsRelation: AnyObject! = userPassed.objectForKey("KfriendsRelation") {
println(friendsRelation)
if friendsRelation != nil {
let findUser : PFQuery = friendsRelation.query()
findUser.whereKey("objectId", notEqualTo: PFUser.currentUser().objectId)
findUser.findObjectsInBackgroundWithBlock....
What should i do if i want to retrieve all users that follow user 1 ?
I made this but it doesn't work :
let findUser : PFQuery = PFQuery(className: "kfriendsRelation")
findUser.whereKey("User", equalTo: user 1)
findUser.findObjectsInBackgroundWithBlock...
jean-marie castellucci
4,954 Pointsjean-marie castellucci
4,954 PointsAlso tried this but dosn't work :