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 9190143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:23:39+00:00 2026-06-17T20:23:39+00:00

I am using Parse.com to store data for an iOS app. The code below

  • 0

I am using Parse.com to store data for an iOS app. The code below successfully retrieves all values in a nested array belonging to a PFObject “game”. However, if I need to query for another array (at the same level as “winners” (say “losers”) i cannot get it to work, and not all the values in the array losers gets populated. I suppose i could do them all on the main thread and not try to nest the fetches (nested blocks) but i’m wondering if:

1) Is the way i’m storing my data prohibiting me from using Parse’s built in query/fetch functionality properly? Data stored as:

PFObject * newGame = [PFObject objectWithClassName:@"Game"];
NSArray * winner = [NSArray arrayWithObjects:[_allPlayersPFDictionary objectForKey:[playerData objectAtIndex:0]], [playerData objectAtIndex:1], nil];
[_gamePF addObject:winner forKey:@"winners"];

2) Is there a better, cleaner way to do the query and get ALL the values of all nested arrays of data in a query? Again, winners is not a PFObject, but is an array of array of PFObject of 2 different types ([PFObject fetchAll:(NSArray *)winnersArray] does not work, because all objects in the Array must be of the same ‘type’ of PFObject). I store it this way because each winning player has another PFObject (1 to many) “powers” associated with them.

Here is the query that works but i can’t figure out how to add “losers” to it and properly populate all data in the background.

PFQuery * gamesQuery = [PFQuery queryWithClassName:@"Game"];
[gamesQuery orderByDescending:@"createdAt"];
gamesQuery.limit = 30;
[gamesQuery findObjectsInBackgroundWithBlock:^(NSArray * theGames, NSError * error) {
    if (error) {
        NSLog(@"ERROR: There was an error with the Query to get Games!");
    } else {
        for (PFObject * aGame in theGames) {
            for (NSArray * aWinner in [aGame objectForKey:@"winners"]) {
                [[aWinner objectAtIndex:0] fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
                    if (error) {
                        NSLog(@"ERROR: There was an error with the Query to get Player in winnersArray!");
                    } else {
                        [PFObject fetchAllIfNeededInBackground:[aWinner objectAtIndex:1] block:^(NSArray *objects, NSError *error) {
                            if (error) {
                                NSLog(@"ERROR: There was an error with the Query to get Powers in winnersArray!");
                            } else {
                             [_gamesPF addObject:aGame];
                                NSLog(@"Games from viewDidLoad %@", _gamesPF);
                                [_tableView reloadData];
                            }
                        }];
                    }
                }];
            }
        }
    }
}];
  • 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-17T20:23:40+00:00Added an answer on June 17, 2026 at 8:23 pm

    Well… i feel kinda stupid. Definitely much easier to use Parse in an object oriented manner for the data model. Was able to easily solve it by remodeling the data to be:

    Game (PFObject *) has:

    --> winners { (PFObject *), (PFObject *), ..., nil }
    --> losers  { (PFObject *), (PFObject *), ..., nil }
    

    where a winner is created as:

    [testWinner1 addObject:power1 forKey:@"power"];
    [testWinner1 addObject:power2 forKey:@"power"];
    [testWinner1 addObject:[_playerPFDictionary objectForKey:@"Tom"] forKey:@"player"];
    

    Which then makes the query much easier and involves only one background block like so:

    PFQuery * gameQuery = [PFQuery queryWithClassName:@"TestGame"];
    [gameQuery includeKey:@"winners.player"];
    [gameQuery includeKey:@"winners.power"];
    [gameQuery includeKey:@"losers.player"];
    [gameQuery includeKey:@"losers.power"];
    [gameQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (error) {
            NSLog(@"failed");
        } else {
            NSLog(@"testGame: %@", [objects objectAtIndex:0]);
        }
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using mechanize to parse http://www.hammacher.com/Category/Default.aspx?uq=Gifts-Under-30&all=True What xpath can I use to get to
I am using the excellent Parse as a data store, but need to access
I am looking to parse XML data (using this URL: https://gdata.youtube.com/feeds/api/videos/ijudAdhLGmg?v=2 ) and get
I'm using Java to parse HTML from a random website, let's say it's http://google.com
I am trying to parse the following using Dom parser in Android. <offerURL> http://statTest.dealtime.com/DealFrame/DealFrame.cmp?bm=553&BEFID=93767&aon=%5E1&MerchantID=434524&crawler_id=1909400&dealId=TCk4NTG97Aa3wSQgh2U3FQ%3D%3D&url=http%3A%2F%2Frover.ebay.com%2Frover%2F1%2F707-64686-24023-0%2F2%3Fipn%3Dpsmain%26icep_item_id%3D190622592957%26icep_vectorid%3D260601%26kwid%3D1%26mtid%3D637%26crlp%3D1_260601%26kw%3D%7Bquery%7D%26query%3D%7Bquery%7D%26linkin_id%3D%7Blinkin_id%7D%26sortbid%3D%7Bbidamount%7D%26fitem%3D190622592957%26mt_id%3D637&linkin_id=7000251&Issdt=120323134700&searchID=p2.77722a731149145f60fa&DealName=Samsung+B2100+Outdoor+In+Schwarz+%28black%29+Orig.+Neuware&dlprc=89.95&crn=&istrsmrc=1&isathrsl=0&AR=1&NG=3&NDP=6&PN=1&ST=7&DB=sdcprod&MT=phx-pkadu-intl-dc20&FPT=DSP&NDS=&NMS=&MRS=&PD=95929320&brnId=14863&IsFtr=0&IsSmart=0&DMT=&op=&CM=&DlLng=7&RR=1&cid=&semid1=&semid2=&IsLps=0&CC=0&SL=0&FS=1&code=&acode=538&category=&HasLink=&frameId=&ND=&MN=&PT=&prjID=&GR=&lnkId=&VK=
So I'm using Parse for now to run the backend of my app. When
Here is the current code I am using to parse the URL and it's
I am trying to get a webpage to parse using the following code. <var-def
What I am trying to do I am using the code below to download
I am developing a website in node.js and I am using Parse.com to handle

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.