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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:05:50+00:00 2026-05-27T18:05:50+00:00

In my application I catch the response from server in json format, something like

  • 0

In my application I catch the response from server in json format, something like this:

{"hotels":
  {"data":
    [{"id":"id1",
    "country":"counry1",
    "state":"state1",
    "city":"city1",
    }
    {"id":"id2",
     "country":"counry2",
     "state":"state2",
     "city":"city2",
    }]
  }
}

If I try to access to element by this code

ID = [[[ParsedResponse objectForKey:@"hotels"] objectForKey:@"data"] valueForKey:@"id"];

everything is ok. But if I do

NSMutableDictionary *ItemsFromParsedResponse = [[NSMutableDictionary alloc] init];
ItemsFromParsedResponse = [ParsedResponse valueForKeyPath:@"hotels.data"];
while (ItemsFromParsedResponse = (NSMutableDictionary*)[ParsedResponseEnumerator nextObject]) {
    ID = [ItemsFromParsedResponse valueForKey:@"id"];
}

ID is [null]. And I don’t understand, why.
Thanks for any advice.

  • 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-05-27T18:05:50+00:00Added an answer on May 27, 2026 at 6:05 pm

    You’re either doing something strange here, or we don’t have all your code. I would write your failing piece of code as follows:

     itemsFromParsedResponse = [parsedResponse valueForKeyPath:@"hotels.data"];
    
     for (NSDictionary *jsonFragment in itemsFromParsedResponse) {
         jsonID = [jsonFragment valueForKey:@"id"];
     } 
    

    I’ve followed the convention of variable names beginning with a lowercase character (starting with an uppercase character should be reserved for class names), and I’m using fast enumeration, bearing in mind that the information at hotels.data is an NSArray. I’ve also renamed ID to jsonID to avoid confusion with the id pointer.

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

Sidebar

Related Questions

Restful Service (from Server) @GET @Produces(application/json) @Consumes(application/json) @Path(/getStatus/) // server:8080/server/rest/admin/status/whatSoEver public void getStatus( @Context
i want to send data from android application to local server (PHP) but it
This is the script that works: curl -H 'content-type:application/json' -d '{userrequest: {username: testname, status:
Retrieving data from the REST Server works well, but if I want to post
I make Android application which must receive data from the page http://example.com/get.php?id=1 . For
the problem is that when i want to get the response from the server
I'm connecting to a web server from my android application via HttpsUrlConnection or HttpUrlConnection
one my application features is tod download files from our ftp server. And of
I am using following code to get data from the Server and if the
I connect a database on my server from the Android application and I want

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.