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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:31:56+00:00 2026-06-15T19:31:56+00:00

I have managed to get a list of locations from my webserver using JSON

  • 0

I have managed to get a list of locations from my webserver using JSON and have the file grabbed from the app.
I know it can get the etc as I have printed it too the NSLog and it appears in JSON in the log window.

My next step is getting these values into an array so I can eventually display them into a UIPickerView.

Anybody any suggestions on how I can best get them into an array from the current JSON file?

Key is ‘name’.

I can’t for the life of me get it to loop through and add to array; maybe I am doing it wrong?

JSON data looks like:

[{"Name":"Aberdaron"},{"Name":"Aberdeen"},{"Name":"Aberdovey"},{"Name":"Aberporth"},{"Name":"Aberystwyth"},{"Name":"Albert-Bridge"},{"Name":"Aldeburgh"},{"Name":"Allington-Lock"},{"Name":"Alloa"},{"Name":"Amble"},{"Name":"Amlwch"},{"Name":"Annan-Waterfoot"},{"Name":"Anstruther-Easter"},{"Name":"Applecross"},{"Name":"Appledore"},{"Name":"Arbroath"},{"Name":"Ardglass"},{"Name":"Ardnave-Point"},{"Name":"Ardrossan"},{"Name":"Arklow"},{"Name":"Arnside"},{"Name":"Arrochar"}]

Code that I have so far is:

    NSString * urlString = [NSString stringWithFormat:@"http://localhost:8888/Locations.php"];
NSURL * url = [NSURL URLWithString:urlString];
NSData * data = [NSData dataWithContentsOfURL:url];
NSError * error;
NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"%@",json);
  • 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-15T19:31:58+00:00Added an answer on June 15, 2026 at 7:31 pm

    The first answer has given a good description of how to parse the array and put it into a native object. I have written a function which is a category on NSString that you can use below. Assuming that your array is stored in a variable called json, I would use the following code, given your example:

    NSMutableArray *nameArray = [NSMutableArray array];
    for (NSDictionary *dictionary in json)
    {
        [nameArray addObject:[dictionary valueForKey:@"Name"]];
    }
    NSLog(@"%@",nameArray);
    

    Now nameArray is an array of all the values corresponding to the “name” keys given in your example.

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

Sidebar

Related Questions

I have a simple list, which I managed to get in a line and
I'm writing a MVC website and using jqGrid. I have managed to get it
So I have managed to get this query working List<string> listStatus = new List<string>()
I have managed to get the following working: var transactions = from t in
I have managed to get a list of the sheets and macros of a
I'm using the EntityFramework (for the first time) and have managed to get as
I have managed using the YouTube API to fetch thumbnails for my list of
I have managed to get a cron job to run a rake task by
Ok so I have managed to get the format of the date presented in
So far I have managed to get the background image to stretch: XHTML: <div

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.