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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:53:08+00:00 2026-06-01T10:53:08+00:00

I need help in retrieving a JSON object and parsing the array into my

  • 0

I need help in retrieving a JSON object and parsing the array into my UIPickerView with 2 columns. One column is the data retrieve from JSON, the other column is hard coded.
Is there any sample codes for parsing the JSON into the UIPickerView column?

  • 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-01T10:53:10+00:00Added an answer on June 1, 2026 at 10:53 am

    I got you some code to get you started, but please keep in mind that:
    It is not optimized code (for example the call you make to fetch your data is executed in the main thread. In case you need to fetch large amounts of data you must make asynchronous calls).
    Its crucial to understand how the UIPickerView delegate & datasource is implemented.
    I hope that this will get you on the right track…

    // Get your JSON Data
    NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.mydomain.com/myjson.json"]];
    
    // Convert your JSON object to an 'NS' object
    NSError *error;
    id myJsonObj = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error];
    
    // Extract any data from your JSON object
    
    NSArray *myFirstArray = ...; // Your fixed array
    NSArray *mySecondArray = ...; // An array with data from your JSON
    
    
    // In your UIPIckerView datasource
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
    {
        return 2;
    }
    
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
    {
        switch(component)
        {
            case 0:
                // First component
                return [myFirstArray count];
                break;
            case 1:
                // Second component
                return [mySecondArray count];
                break;
            default:
                return 0;
                break;
        }
    
        return 0;
    }
    
    
    // In your UIPIckerView delegate
    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
    {
        switch(component)
        {
            case 0:
                // First component
                return [myFirstArray objectAtIndex:row]; // We assume that you got NSString objects in the array
                break;
            case 1:
                // Second component
                return [mySecondArray objectAtIndex:row]; // We assume that you got NSString objects in the array
                break;
            default:
                return 0;
                break;
        }
    
        return @"";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with some PHP code. I am retrieving data from a MySQL
Need help writing a script downloads data from google insight using c# this is
I'm retrieving image from DB using Stream. Need someone to help me to convert
I'm having difficulty in retrieving values from a Json array. I have a Json
I need to return a list of objects from a restful webservice. each object
I really need some help... I detail my problem, I need an array of
I am retrieving data from a SQL table so I can display the result
Hello and thanks in advance. I am retrieving data from the db. The data
I need to get value from json. It works perfectly on returned objects, but
basically I am parsing a xml file and retrieving certain elements from that xml

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.