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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:02:57+00:00 2026-05-29T10:02:57+00:00

I have been reading up on pickers and wanted to try and get a

  • 0

I have been reading up on pickers and wanted to try and get a simple one working, but I do not know what I am doing wrong with my code.

I have assigned my pickers in my storyboard to the correct controllers. I then added the following to my header.

@interface CustomerView : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>
{
    IBOutlet UIPickerView * CompanyPicker;
IBOutlet UIPickerView * ClientPicker;
    NSMutableArray *arrayCompanies;
NSMutableArray *arrayClients;
}

I then added some info to the arrays I created in my heading under didload:

  arrayCompanies = [[NSMutableArray alloc] init];
  [arrayCompanies addObject:@"Test Company 01"];
  [arrayCompanies addObject:@"Test Company 02"];
  [arrayCompanies addObject:@"Test Company 03"];
  [arrayCompanies addObject:@"Test Company 04"];
  [arrayCompanies addObject:@"Test Company 05"];
  [arrayCompanies addObject:@"Test Company 06"];
  [arrayCompanies addObject:@"Test Company 07"];

  arrayClients   = [[NSMutableArray alloc] init];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];
  [arrayClients addObject:@"Test Client 01"];

After that I added the following in the implementation, but the info is not seeming to load into my arrays. Am I doing something wrong here?

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {

  return 2;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {

return [arrayCompanies count];
  return [arrayClients count];
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

return [arrayCompanies objectAtIndex:row];
    return [arrayClients objectAtIndex:row];
}

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

NSLog(@"Selected Company: %@. Index of selected company: %i", [arrayCompanies objectAtIndex:row], row);
  NSLog(@"Selected Client: %@. Index of selected client: %i", [arrayClients objectAtIndex:row], row);
}
  • 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-29T10:02:58+00:00Added an answer on May 29, 2026 at 10:02 am

    use this technique:

    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
    
      return 1;
    }
    
    - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
    if ([thePickerView isEqual: CompanyPicker]) {
     return [arrayCompanies count];
    } else if ([thePickerView isEqual: ClientPicker]) {
      return [arrayClients count];
    }
     return 0;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading so many topics here about this, but I could not
I have been reading the Phing documentation and it makes sense, but I'm not
I have been reading over a lot of questions, but cant seem to find
I have been reading the doc and searching but cannot seem to find a
I have been reading about branch prediction but the only implementation I find are
I have been reading this blog post and this stack overflow post but I
I have been reading error LNK2019 for ZLib sample code compiling - But was
I have been reading up on Reference and value types. I get the idea.
I have been reading for a while regarding Hibernate but I can't seem to
I have been reading about garbage collection and came to know the term Island

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.