Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Where dose this code go?

I'm making a App to quickly tweet how Im feeling about something and im not sure where the set of code below gose.

I know somewhere in "InstatwitViewController.m", but my book dosnt show where in the file I'm suppost to put it?


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)

pickerView {

return2;

}

- (NSInteger)PickerView:(UIPickerView *)

pickerViewnumberOfRowsInComponent :(NSInteger)component {

if (component == 0) {

return [activities count];


}


else {

return [feelings count];

}

}


I'm sorry im so dumb and can't figure it out, but help WILL be greatly appreciated! 🙂

Posted on Feb 20, 2012 12:52 PM

Reply
Question marked as Best reply

Posted on Feb 20, 2012 9:10 PM

Those are UIPickerViewDataSource protocol methods.

https://developer.apple.com/library/ios/#documentation/iPhone/Reference/UIPicker ViewDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIPickerVi ewDataSource


Generally the view controller containing the UIPickerView adopts the UIPickerViewDataSource protocol and includes the appropriate methods. If you have dropped the UIPickerView on a storyboard scene, the dataSource outlet should reference the same view controller.


Same thing applies to UIPickerViewDelegate protocol.


It doesn't matter where in the module the methods are placed. To make them easy to find, consider adding these lines immediately above each group of methods.


#pragma mark - Picker view datasource


#pragma mark - Picker view delegate

2 replies
Question marked as Best reply

Feb 20, 2012 9:10 PM in response to NoSco

Those are UIPickerViewDataSource protocol methods.

https://developer.apple.com/library/ios/#documentation/iPhone/Reference/UIPicker ViewDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIPickerVi ewDataSource


Generally the view controller containing the UIPickerView adopts the UIPickerViewDataSource protocol and includes the appropriate methods. If you have dropped the UIPickerView on a storyboard scene, the dataSource outlet should reference the same view controller.


Same thing applies to UIPickerViewDelegate protocol.


It doesn't matter where in the module the methods are placed. To make them easy to find, consider adding these lines immediately above each group of methods.


#pragma mark - Picker view datasource


#pragma mark - Picker view delegate

Where dose this code go?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.