Reputation: 2079
I'm a IOS noob and I'm trying to understand how to set the datasource of of the uipicker view i have followed This tutorial, everything seems to work correctly however i get a warning in xcode that says
'id<UIPickerViewDataSource>' from incompatible type 'StateViewController *const __strong'
it occurs on this line.
myPickerView.delegate = self;
I keep trying different things but they all lead me in the same direction. It fails. How should i be doing this? how to i properly set the datasource of a UIpicker view.
Thanks in advance for your guidance.
Upvotes: 0
Views: 99
Reputation: 11247
Step 1: Add UIPickerViewDataSource
delegate in your header file
@interface StateViewController : UIViewController <UIPickerViewDataSource>
Step 2: Now add the following line in your class file
myPickerView.dataSource = self
Upvotes: 1
Reputation: 14722
You need to say
myPickerView.dataSource = self
and also
<UIPickerViewDataSource>
Upvotes: 1
Reputation: 104092
You just need to tell the compiler that you're going to conform to the delegate protocol. You do that by adding <UIPickerViewDataSource>
to your .h file,
@interface StateViewController : UIViewController <UIPickerViewDataSource>
Upvotes: 2