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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:36:12+00:00 2026-05-15T06:36:12+00:00

I have a class with 4 arrays: tab_1,tab_2,tab_3 and tab_T. I set the picker’s

  • 0

I have a class with 4 arrays: tab_1,tab_2,tab_3 and tab_T.
I set the picker’s delegate and datasource to self (which is the class containing the arrays).

The picker is called when textfields begin editing. I return NO in order to prevent the keyboard from being shown. I have a method animating the picker instead.

Depending on which textfield is touched i do:
tab_T=tab_1; or 2 or 3

In my opinion this assignment makes tab_T the datasource of the picker. Is this assignment really binding the array tab_T to the datasource?
Is there a way to manually assign it? i’m sure there is. But picker.datasource=tab_1 doesn’t work. i got a ” warning: class ‘NSMutableArray’ does not implement the ‘UIPickerViewDataSource’ protocol”.

Its my first app maybe i am forgetting a step i did at the early ages of my app.

Looking forward to anyone willing to help.

Wallou

  • 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-15T06:36:12+00:00Added an answer on May 15, 2026 at 6:36 am

    A UIPickerView’s datasource has to be a class that implements the UIPickerViewDataSource protocol. The populating of the picker view is done in these two methods:

    – numberOfComponentsInPickerView:  
    – pickerView:numberOfRowsInComponent: 
    

    Since NSArray doesn’t implement the protocol using:

    pickerView.datasource=someArray;
    

    … generates the error you’ve seen saying the array does not implement the protocol.

    The first thing you need to do is to declare that your controller implements the protocol like so:

    @interface MyControllerClass: UIViewController <UIPickerViewDataSource,UIPickerViewDelegate> 
    

    then you need to implement the protocol’s methods which will look something like:

    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
        return 1; //or whatever
    }
    
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
        return [self.tab_T count]; // assuming just one component
    }
    

    To actually populate the components, you need the UIPickerViewDelegate methods. (I know it seems that the datasource should provide, you know, data but for some reason they have it backwards.)

    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
        return [self.tab_T objectAtIndex:row]; //assuming one component
    }
    

    The key idea here is that the objects that implement the datasource and delegate methods serve as the interface between the picker and whatever data structure actually holds the data. In this case, its just simple arrays but it could be anything including Core Data, SQL or downloaded from a URL.

    The pickerview never directly deals with the data structure at all. It’s always the object/s that implement the datasource and delegate methods that do the interaction.

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

Sidebar

Related Questions

I have a class that stores paths to CSS and Javascript files in arrays.
I have a dummy class where I am testing arrays. I've noticed that when
I've got a class with many string arrays. I'd like to have one generic
I have a base class object array into which I have typecasted many different
So i have a class name repository which is just a simple array.Here is
I have a grid view which is populated using a custom ImageAdapter class extending
I have created a class for a dashboard item which will hold information such
In Java, the java.util.Arrays class have several static toString(...) methods that take an array
I have the template class and array of pointers to objects and overloaded logic
I have a class with a 2D array of ints implemented as an int**.

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.