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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:20:49+00:00 2026-06-06T20:20:49+00:00

I call an URL that returns me JSON (I use JSONKit). I convert it

  • 0

I call an URL that returns me JSON (I use JSONKit). I convert it to a NSString that is this way:

[{"name":"aaaaaa","id":41},{"name":"as","id":23},...

And so on. I want to fill an UIPickerView with only the “name” part of the JSON. But, when the user selects a name, i need the “id” parameter, so i’ve thought to fill a NSDictionary with the JSON (setValue:id for key:name), so i can get the value picked by the user, and get the id from the dictionary. how could I fill an array with only the “name” of the JSON?

Im a bit lost with the JSONKit library, any guidance? Thank you.

  • 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-06T20:20:51+00:00Added an answer on June 6, 2026 at 8:20 pm

    First of all I don’t think that its a good idea to have name as key in a dictionary, since you can have many identical names. I would go for id as key.

    Now, what you could do is:

    NSString *myJson; //Suppose that this is the json you have fetched from the url
    id jsonObject = [myJson objectFromJSONString];
    // Now you have an array of dictionaries 
    // each one having 2 key/value pairs (name/id)
    
    NSArray *names = [jsonObject valueForKeyPath:@"name"];
    NSArray *ids = [jsonObject valueForKeyPath:@"id"];
    
    // Now you have two parallel arrays with names / ids
    

    Or you could just iterate your json object and handle the data yourself:

    for (id obj in jsonObject)
    {
      NSString *name = [obj valueForKey:@"name"];
      NSNumber *id = [obj valueForKey:@"id"];
      // Do whatever you like with these
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want Play to call a webservice. The webservice accepts application/json and returns this
I've a problem...I use jQuery ajax to call a web service that returns XML.
I have a web page that returns this JSON when called: [{id:53,desc:Roberts}] I am
I have a call back url, that i'm am pulling out the Lat and
If I have a string that contains a url (for examples sake, we'll call
I want to call a url with passing some parameter and i want to
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:
I am performing a jQuery .ajax() call that returns a List<string> of IP addresses
I have a simple ajax call like this: $.ajax({ url: u, type: POST, dataType:
I want to use jQuery to make a call to a c# web service

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.