I've seen examples of picker views used where the values for the picker are hardcoded into the source code like this
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString * title = nil;
switch(row) {
case 0:
title = @"a";
break;
case 1:
title = @"b";
break;
case 2:
title = @"c";
break;
}
However, if you're going to have 100 numbers in your picker view that would be very impractical. I'm sure you can see what I'm trying to do below. It's giving me the error
expression is not an integer constant expression
How can I get the numbers from 0 to 100 in a picker view? Feel free to comment if there's a better way to get input where a user selects a number between 1 and 100.
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString * title = nil;
if (pickerView.tag == 1) // this is otherPickerview
{
otherpickerview
for (int i = 2; i < 100; i++){
switch(row) {
case i:
title = [NSString stringWithFormat:@"%d", i];
break;
}
}
}