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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:55:12+00:00 2026-06-07T02:55:12+00:00

Perhaps I am over-thinking or confusing myself, but my head is stuck in a

  • 0

Perhaps I am over-thinking or confusing myself, but my head is stuck in a loop over this and I cannot break out.

I have a a JSON of the format: (Validated at http://jsonformatter.curiousconcept.com/)

{
  id: 1,
  sections: "5",
  total: "10",
  result: {
    3: 00PM: [
      {
        name: "Anurag",
        status: "Web"
      },
      {
        name: "Anurag2",
        status: "Web2"
      }
    ],
    5: 00PM: [
      {
        name: "Anurag",
        status: "Seated"
      }
    ],
    6: 00PM: [
      {
        name: "Anurag4",
        status: "Web4"
      },
      {
        name: "Anurag5",
        status: "Web5"
      },
      {
        name: "Anurag6",
        status: "Web6"
      },
      {
        name: "Anurag7",
        status: "Web7"
      }
    ]
  }
}

I have this so far:

        NSDictionary *dict = [response JSONValue];
        NSDictionary *results = [dict objectForKey:@"result"];

        NSInteger num_results = [[dict valueForKey:@"total"] intValue];
        NSInteger num_sections = [[dict valueForKey:@"sections"] intValue];

        NSMutableArray *sections = [[NSMutableArray alloc] initWithCapacity:num_sections];
        NSMutableArray *objarr = [[NSMutableArray alloc] initWithCapacity:num_results];
        NSMutableArray *obj= [[NSMutableArray alloc] initWithCapacity:num_sections];
        NSMutableArray *temp = [[NSMutableArray alloc] initWithCapacity:num_results];

        for (NSString* key in results) {
            NSLog(@"Key: %@", key); // prints out 3:00 PM...5:00 PM etc...
            [obj addObject:[results objectForKey:key]]; // nested objects within each key are saved in the array
            NSLog(@"Object 1: %@", obj);
        }

        for (int i = 0; i < [obj count]; i++) {
            //NSLog(@"Object 2: %@", [obj objectAtIndex:i]);
            [temp addObject:[obj objectAtIndex:i]]; // I take each object from previous array and save it in a temp array
            for (int i = 0; i < num_results; i++) {
                NSLog(@"Object 3: %@", [temp objectAtIndex:i]);
                **[objarr addObject:[temp objectAtIndex:i]]; // I want to extract the object within the object but cannot get it to work**
            }   
        }

I am able to make an array of objects within each of the 3 keys inside results. But I am not able to get each of the objects inside them as a separate object and save them in an array.

For example, in an NSArray I have:

Object 3: (
        {
        name = "Anurag ";
        status = Web;
    },
        {
        name = "Anurag ";
        status = Web;
    }
)

How can I get the two objects inside this object and save them both in an array?
I guess the main issue is I cannot refer to a key name to get the individual object.

  • 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-07T02:55:13+00:00Added an answer on June 7, 2026 at 2:55 am

    You can use the following code,

    NSDictionary *json = [response JSONValue];
    
    // Get the objects you want
    NSArray *items = [json valueForKeyPath:@"result.6: 00PM"];
    

    This will return an NSArray with the objects for the key 6: 00PM

    Please check this link too.

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

Sidebar

Related Questions

Perhaps I am over thinking this, but I would like to understand the purpose
this newbie here is smacking his head with webservices over Rails. Perhaps someone could
I've already seen this question but it's been asked over a year ago. Perhaps
Perhaps any of you can help me with this anoying problem. I have long
Perhaps this is an effect of installing the new 4.5 beta, but my simulator
Perhaps I'm being over-ambitious, but I'm trying to write a server program which can
Perhaps I'm over-looking some minor error somewhere, however I have spent 20 minutes staring
I just can't fathom the logic, perhaps I'm over thinking it! I need to
Perhaps this is best asked on the wxPython mailing list, but I thought I'd
Perhaps you can help me find this in the docs. I'm using pound-quote to

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.