UIPickerView with 2 NSMutableArrays?

You are asking to use the same object as the delegate for two pickers In each of the delegate methods, the picker is provided as the first argument for this purpose. You can check which picker is passed in and return the appropriate data for that picker For example, if you add a property for the first picker named "pickerOne" and you second mutable array is called "arrayTwo", the delegate methods would look like this: (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)picker; { return 1; // assuming both pickers only have 1 component } - (void)pickerView:(UIPickerView *)picker didSelectRow:(NSInteger)row inComponent: (NSInteger)component { // The label is simply setup to show where the picker selector is at if (picker == self. PickerOne) { label.

Text= listOfItems objectAtIndex:row; } else { label. Text= arrayTwo objectAtIndex:row; } } - (NSInteger)pickerView:(UIPickerView *)picker numberOfRowsInComponent:(NSInteger)component; { if (picker == self. PickerOne) { return listOfItems count; } else { return arrayTwo count; } } - (NSString *)pickerView:(UIPickerView *)picker titleForRow:(NSInteger)row forComponent: (NSInteger)component; { if (picker == self.

PickerOne) { return listOfItems objectAtIndex:row; } else { return arrayTwo objectAtIndex:row; } } Also, you can populate your array like this (if you just have a static list of strings, the array does not need to be mutable): listOfItems = NSArray alloc initWithObjects:@"Baptisms",@"Greenland",@"Switzerland",@"Norway",@"New Zealand",@"Greece",@"Rome",@"Ireland",nil.

You are asking to use the same object as the delegate for two pickers. In each of the delegate methods, the picker is provided as the first argument for this purpose. You can check which picker is passed in and return the appropriate data for that picker.

For example, if you add a property for the first picker named "pickerOne" and you second mutable array is called "arrayTwo", the delegate methods would look like this: - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)picker; { return 1; // assuming both pickers only have 1 component } - (void)pickerView:(UIPickerView *)picker didSelectRow:(NSInteger)row inComponent: (NSInteger)component { // The label is simply setup to show where the picker selector is at if (picker == self. PickerOne) { label. Text= listOfItems objectAtIndex:row; } else { label.

Text= arrayTwo objectAtIndex:row; } } - (NSInteger)pickerView:(UIPickerView *)picker numberOfRowsInComponent:(NSInteger)component; { if (picker == self. PickerOne) { return listOfItems count; } else { return arrayTwo count; } } - (NSString *)pickerView:(UIPickerView *)picker titleForRow:(NSInteger)row forComponent: (NSInteger)component; { if (picker == self. PickerOne) { return listOfItems objectAtIndex:row; } else { return arrayTwo objectAtIndex:row; } } Also, you can populate your array like this (if you just have a static list of strings, the array does not need to be mutable): listOfItems = NSArray alloc initWithObjects:@"Baptisms",@"Greenland",@"Switzerland",@"Norway",@"New Zealand",@"Greece",@"Rome",@"Ireland",nil.

Wow, thank you! That was perfect! – Steve Jan 19 '10 at 11:07.

Xib file has such elements as a datePicker, textField, numberSlider, and where my problem is coming from a UIPickerView, that are all controlled within one view using . Hidden = YES/NO; expressions. My problem is that I need to populate a UIPickerView in two seperate screens, that need to have two different NSMutableArray sources.

And that works fine for the first attribute and array. So then after that, when a different uitableviewcell is selected, the picker is hidden picker.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions