Alright, I’m having the following common problem
[NSCFNumber isEqualToString:]: unrecognized selector sent to instance
but this time I’m not sure how to fix it.
Here’s the declaration in viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
NSMutableArray *tempHours = [NSMutableArray array];
for (int i = 0; i < 12; i++) {
[tempHours addObject:[NSNumber numberWithInt:(i+1)]];
}
self.hours = tempHours; // 'hours' is a synthesized NSArray property of the ViewController
[tempHours release];
// two more similar array declarations here
}
Here’s the code method of the UIPickerView where stuff breaks (e.g., the if statement)
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString *stringIndex = [NSString stringWithFormat:@"Row #%d", row];
if(component == 0) {
return stringIndex = [self.hours objectAtIndex:row];
}
// more code for other components (of the same form) here
return stringIndex;
}
I think I need my NSArray of NSNumber objects to be type-casted as strings. How do I do that properly with that statement:
stringIndex = [self.hours objectAtIndex:row];
Thanks!
1 Answer