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

  • Home
  • SEARCH
  • 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 8791441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:36+00:00 2026-06-13T22:50:36+00:00

I’m returning JSON with a rough structure like the one below, and I’m trying

  • 0

I’m returning JSON with a rough structure like the one below, and I’m trying to figure out how I can count how many platforms there are (in this case, three, but could be anything from 1 to 20 or so). I’ve returned the JSON into an NSDictionary and am using lines such as these to retrieve the data I need:

_firstLabel.text = _gameDetailDictionary[@"results"][@"name"];

In the above case, it’ll grab the name from the results section. Since there are multiple platforms, I need to construct a loop to cycle through each name inside the platforms section. Not too sure how to go about that. All help appreciated!

"results":{
    "platforms":[
        {
            "api_detail_url":"http://",
            "site_detail_url":"http://",
            "id":18,
            "name":"First Name"
        },
        {
            "api_detail_url":"http://",
            "site_detail_url":"http://",
            "id":116,
            "name":"Second Name"
        },
        {
            "api_detail_url":"http://",
            "site_detail_url":"http://",
            "id":22,
            "name":"Third Name"
        }
    ],

EDIT: Here’s my fetchJSON method:

- (NSDictionary *) fetchJSONDetail: (NSString *) detailGBID {

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible: YES];

    NSString *preparedDetailURLString = [NSString stringWithFormat:@"http://whatever/format=json", detailGBID];
    NSLog(@"Doing a detailed search for game ID %@", detailGBID);

    NSData *jsonData = [NSData dataWithContentsOfURL: [NSURL URLWithString:preparedDetailURLString]];

    _resultsOfSearch = [[NSDictionary alloc] init];
    if (jsonData) {
        _resultsOfSearch = [NSJSONSerialization JSONObjectWithData: jsonData
                                                           options: NSJSONReadingMutableContainers
                                                             error: nil];
    }

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible: NO];

    NSString *results = _resultsOfSearch[@"number_of_page_results"];
    _numberOfSearchResults = [results intValue];

    NSArray *platforms = [_resultsOfSearch valueForKey:@"platforms"];
    int platformsCount = [platforms count];
    NSLog(@"This game has %d platforms!", platformsCount);

    return _resultsOfSearch;

}

  • 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-13T22:50:37+00:00Added an answer on June 13, 2026 at 10:50 pm

    The “platforms” JSON field is an array, so assuming you’ve de-serialised the JSON using something like,

    NSMutableDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:resultsData options:NSJSONReadingMutableContainers error:&error];
    

    Then, you can assign platforms to an NSArray,

    NSDictionary *results = [responseJSON valueForKey:@"results"];
    
    NSArray *platforms = [results valueForKey:@"platforms"];
    

    …and find the number of platforms via,

    int platformsCount = [platforms count];
    

    In your case, where you want to iterate through the platforms, you can use,

    for (NSDictionary *platform in platforms)
    {
        // do something for each platform
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I would like to count the length of a string with PHP. The string
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is

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.