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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:28:40+00:00 2026-05-22T11:28:40+00:00

I have a pickerview with 2 rows and I need to fill them automatically.

  • 0

I have a pickerview with 2 rows and I need to fill them automatically. First row: numbers from 150 to 210 and second row: from 40 to 130. Can anyone help me with this?

My code:

- (void)viewDidLoad {

    NSArray *ar1 = [[NSArray alloc]initWithObjects:@"150", @"151", @"152", nil];
    self.array1 = ar1;
    [ar1 release];

    NSArray *ar2 = [[NSArray alloc]initWithObjects:@"40", @"41", @"42", nil];
    self.array2 = ar2;
    [ar2 release];

        [super viewDidLoad];

}
  • 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-22T11:28:41+00:00Added an answer on May 22, 2026 at 11:28 am

    You shoulf use for loop for that. The code:

    NSArray *ar1 = [NSArray array];
    for (int i = 150; i <= 210; i++)
        ar1 = [ar1 arrayByAddingObject:[NSString stringWithFormat:@"%d",i]];
    [ar1 retain];
    self.array1 = ar1;
    
    NSArray *ar2 = [NSArray array];
    for (int j = 40; j <= 130; j++)
        ar2 = [ar2 arrayByAddingObject:[NSString stringWithFormat:@"%d",j]];
    [ar2 retain];
    self.array2 = ar2;
    

    EDIT: It will be better when you’ll use NSMutableArray instead.

    NSArray *ar1 = [[NSMutableArray alloc] init];
    for (int i = 150; i <= 210; i++)
        [ar1 addObject:[NSString stringWithFormat:@"%d",i]];
    self.array1 = ar1;
    
    NSArray *ar2 = [[NSMutableArray alloc] init];
    for (int j = 40; j <= 130; j++)
        [ar2 addObject:[NSString stringWithFormat:@"%d",j]];
    self.array2 = ar2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three labels, which I want to fill with selected row from pickerview.
I have pickerView with two rows and I need to save position of both
I have a picker view that has a list of numbers to pick from.
I have a custom UIPickerView where I use: -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView
i have added a pickerview from interface builder.i am using this method to show
Have UIPickerView with two rows. Trying to save value of each row in NSUserDefaults
I have a UITableView consisting of three rows - each row is a data
I have got a UIPickerView. When I select a row, this happens: - (void)pickerView:(UIPickerView
I have a UIPickerView with 3 components, I need the first 2 components to
I have my pickerview set up and everything works fine, but right now I

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.