Search code examples
iosobjective-ccocoaparse-platformios-app-extension

Parse- [query findObjectsInBackgroundWithBlock:^.)]; Block Doesn't execute w/ Action Extension


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];
        }
    }];**
}

Solution

  • 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!