Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:09:31+00:00 2026-06-16T05:09:31+00:00

Anyone know how to shrink this, so that I don’t have to run querys

  • 0

Anyone know how to shrink this, so that I don’t have to run querys in the main thread in the QueryForTable method? I’m using Parse.com

//Find who are the users following (RELATIONSHIP OBJECT)
PFQuery *followeesQuery = [PFQuery queryWithClassName:@"Relationship"];
[followeesQuery whereKey:@"Follower" equalTo:[PFUser currentUser]];
NSArray *followees = [followeesQuery findObjects];
//Filter followees
self.followees = [[NSMutableArray alloc] initWithCapacity:[followees count]];
for (int i = 0; i < [followees count]; i++) {
    PFObject *followee = followees[i];
    PFUser *user = (PFUser *)[followee objectForKey:@"User"]; //USER OBJECT
    [self.followees addObject:user];
}


PFQuery *nearbyPhotosQuery = [PFQuery queryWithClassName:@"Photo"]; //PHOTO OBJECT
[nearbyPhotosQuery whereKey:@"User" notContainedIn:self.followees];
[nearbyPhotosQuery whereKey:@"Location" nearGeoPoint:self.userCurrentLocation withinKilometers:10];

PFQuery *followersPhotoQuery = [PFQuery queryWithClassName:@"Photo"]; //PHOTO OBJECT
[followersPhotoQuery whereKey:@"User" containedIn:self.followees];

NSMutableSet *set = [NSMutableSet setWithArray:[nearbyPhotosQuery findObjects]];
[set addObjectsFromArray:[followersPhotoQuery findObjects]];

NSArray *targetPhotoObjects = [set allObjects];

NSMutableArray *targetIDs = [[NSMutableArray alloc] initWithCapacity:[targetPhotoObjects count]];
for (int i = 0; i < [targetPhotoObjects count] ; i++) {
    PFObject *photoObject = targetPhotoObjects[i];
    [targetIDs addObject:photoObject.objectId];
}


PFQuery *targetPhotoQuery = [PFQuery queryWithClassName:@"Photo"];
[targetPhotoQuery whereKey:@"objectId" containedIn:targetIDs];


return targetPhotoQuery;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:09:32+00:00Added an answer on June 16, 2026 at 5:09 am

    If I read this correctly, you want a query for all photos by followers or near you. Why not use:

    PFQuery *followeesQuery = [PFQuery queryWithClassName:@"Relationship"];
    [followeesQuery whereKey:@"Follower" equalTo:PFUser.currentUser];
    
    PFQuery *followeesPhotosQuery = [PFQuery queryWithClassName:@"Photo"];
    [followeesPhotosQuery whereKey:@"User" matchesKey:@"User" inQuery:followeesQuery];
    
    PFQuery *nearbyPhotosQuery = [PFQuery queryWithClassName:@"Photo"];
    [nearbyPhotosQuery whereKey:@"Location"
                   nearGeoPoint:self.userCurrentLocation
                withinKilometers:10];
    
    return [PFQuery orQueryWithSubqueries:@[followeesPhotosQuery, nearbyPhotosQuery]];
    

    This is a query which matches what you’re looking for which doesn’t require server-side trips to create. You may need to play with the maximum number of elements returned by inner queries if you expect more than 100 elements to be returned along any step in the process; each query along the way is subject to its own query limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know how to get this working in gradle for a SUBPROJECT so that
Anyone know how to solve this warning message? Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref
Anyone know how to do this without using a third party program? If there
Anyone know how to set the custom 404 Error pages that the Visual Studio
Anyone know of a tutorial online that explains how to integrate alexbilbie CodeIgniter-OAuth-2.0-Server as
Anyone know an example of phonegap with $.ajax() in github for Android? I have
Anyone know how to do draw sth similar to this in Java and working
Anyone know what the best way is to search on a Field that hold
Anyone know how to remedy this error? Specified cast is not valid. Description: An
I have an app that resizes itself for different views using: NSSize currentSize =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.