所以我有一群朋友测试我的应用程序,一个人在 iPhone 4 上说当他按下我的 PickerView 上的“开始”按钮时应用程序崩溃了。
一点背景知识:用户在 PickerView 中选择值,然后按“Go”。一旦按下“Go”,它就会在数据库中搜索用户选择的值,并在 TableView 中显示结果。
也就是说,它适用于其他两个朋友(在 4S 和 iPhone 5 上)。有谁知道这可能是为什么?请参阅下面的代码(崩溃点)。
选择器视图控制器.m
- (IBAction)buttonpressed:(UIButton *)sender {
NSLog(@"Button Pushed!");
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"pickerGo"])
{
NSLog(@"%@", Strains);
// Get reference to the destination view controller
PickerResultsTableViewController *PickerTableView = [segue destinationViewController];
NSLog(@"%@", PickerTableView);
NSPredicate *ailmentPredicate = [NSPredicate predicateWithFormat:@"Ailment CONTAINS[c] %@", [array1 objectAtIndex:[pickerView selectedRowInComponent:0]]];
NSPredicate *actionPredicate = [NSPredicate predicateWithFormat:@"Action CONTAINS[c] %@", [array2 objectAtIndex:[pickerView selectedRowInComponent:1]]];
NSPredicate *ingestPredicate = [NSPredicate predicateWithFormat:@"Ingestion CONTAINS[c] %@", [array3 objectAtIndex:[pickerView selectedRowInComponent:2]]];
NSCompoundPredicate *resultPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects: ailmentPredicate,actionPredicate,ingestPredicate, nil]];
searchResults = [Strains filteredArrayUsingPredicate:resultPredicate];
// Pass any objects to the view controller here, like...
[PickerTableView setSearchResults: [searchResults copy]];
NSLog(@"%@", searchResults);
}
}