I am populating a pickerView from an array. It loads into the page okay. However, when you scroll through the choices of the pickerView at the 11th choice, it crashes with a [NSNull rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x19fc50490
error.
I really have no idea what to try next and would be grateful for any suggestions:
Here is my code:
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component{
return _actnames.count;//THis logs as 30 as there are 30 possibilities
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
NSLog(@"before crash"); //last line to display before crash
return _actnames[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
_selectedActName = ([_actnames objectAtIndex:row]);
}
The last method is the one where it appears to crash. As mention, it crashes when you select the 11th item, though there are 30.
Thanks for any ideas.
Update:
This is method that pulls actnames from core data:
- (id) getActNames{
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Activities"];
fetchRequest.resultType = NSDictionaryResultType;
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"created" ascending:NO];
[fetchRequest setSortDescriptors:@[sort]];
NSError *error = nil;
self.managedObjectContext = [Model sharedInstance].managedObjectContext;
NSArray *results = [self.managedObjectContext executeFetchRequest:fetchRequest
error:&error];
NSMutableArray * actnames = [[results valueForKey:@"actname"] mutableCopy];
return actnames;
}