1
votes

I'm trying to develop and Action Extension for iOS9.1 that is supposed to query Parse for some data.

I've added, enabled and tested Parse in the extension and I'm successful at creating test objects and checking for current user.

I can not get the code inside Parse's query method [query findObjectsInBackgroundWithBlock:^ to execute. LLDB just keeps skipping it so I'm really at a loss.

This code executes perfectly within the container app so I'm a bit confused.

- (void)viewDidLoad
{
    [super viewDidLoad];
    [Parse enableLocalDatastore];
    [Parse enableDataSharingWithApplicationGroupIdentifier:@"group.com.app.slinky"
                                     containingApplication:@"com.app.Slinky"];

    [Parse setApplicationId:@"xxxxx"
                  clientKey:@"xxxxx"];

    for (NSExtensionItem *item in self.extensionContext.inputItems) {
        for (NSItemProvider *itemProvider in item.attachments) {
            if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypePropertyList]) {
                [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypePropertyList options:nil completionHandler:^(NSDictionary *jsDict, NSError *error) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        NSDictionary *jsPreprocessingResults = jsDict[NSExtensionJavaScriptPreprocessingResultsKey];
                        NSString *pageTitle = jsPreprocessingResults[@"title"];
                        NSString *pageURL = jsPreprocessingResults[@"URL"];
                        if ([pageURL length] > 0) {
                            self.siteURL.text = pageURL;
                            self.URLstring = pageURL;
                        }                            
                        if ([pageTitle length] > 0) {
                            self.siteTitle.text = pageTitle;
                        }   
                    });
                }];
                break;
            }
        }
    }
    [self queryParse];
}


-(void)queryParse{

    PFQuery *query = [self.friendsRelation query];
    [query orderByAscending:@"username"];
    **[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (error) {
            NSLog(@"%@ %@", error, [error userInfo]);
        } else {
            self.friends = objects;
            [self.tableView reloadData];
        }
    }];**
}
2
what is your problem ? I guess you can't fetch whole data from parse by executing query. - Hardik Shekhat
The Bock in [query findObjectsInBackgroundWithBlock:^ does not execute - got2jam

2 Answers

0
votes

There are some limit to fetch Objects from Parse. Read Here

One has a limit of obtaining 100 objects, but anything from 1 to 1000 has a valid limit.

You have to set the limit again for the query for next objects and skip the properties of PFQuery.

You will have to query again and again until you reach the total count.

For Example - If you have 3000 objects to be fetched, then you have to query 3 times with a count of say 1000.

OR

Call [self queryParse]; inside dispatch_async(dispatch_get_main_queue(), ^{ }); block.

Hope this might workout.

0
votes

This was just a result of a 12 hour refractoring marathon :-(

When I moved the queryParse call into its own method. I lost the definition of

self.friendsRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];

essentially sending a bad query... I don't know why it isn't return an error but regardless I can check that off now.

Thank you all for you help!