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

Jack Ryder
Jack Ryder
7,286 Points

Ribbit - How would I Query Parse for users that follow me?

Hi,

Basically wanting to add a feature so i could get the number of followers i have, aka the number of people that have added me on the app. I was wondering what the Parse query would look like?

Thanks!

3 Answers

Jack Ryder
Jack Ryder
7,286 Points

Just queried users that had the [PFUser CurrentUser] in their 'following' array in parse

Without getting into actual code. You're looking at something like this:

  • Find the current user id - PFUser *currentUser = [PFUser currentUser];
  • Get all users - This is similar to code you have used in the "Edit Friends" class
  • Set up an object to hold whatever you're passing. I'd go with: - int x;
  • PFQuery *query = [PFUser query]; [query whereKey:@"friendsRelation" equalTo:currentUser]; // Check Parse Documentation
  • Then if (currentUser is in friendsRelation) - x++; return x; else return x;

NSLog(@"Friends added you %@", x);

Definitely not code, but if you haven't tried the Parse forums, I'd suggest starting there, if you're really stuck. Also check the documentation, such as this page. https://www.parse.com/docs/ios_guide#queries-relational/iOS

Jack Ryder
Jack Ryder
7,286 Points

cheers for the help, Ben Jakuben any ideas on code?