应用程序在iPhone 4上使用此代码崩溃,但在iPhone 4S&五

时间:2013-08-21 15:47:50

标签: ios objective-c uiview uipickerview

所以我有一群朋友测试我的应用程序,iPhone 4上的一个人说当他按下我的PickerView附带的“Go”按钮时应用程序崩溃了。

一些背景知识 用户在PickerView中选择值,然后按“开始”。按下“Go”后,它会在数据库中搜索用户的选定值,并在TableView中显示结果。

那说,它适用于其他两个朋友(在4S和iPhone 5上)。有谁知道为什么会这样?请参阅下面的代码(崩溃点)。

pickerviewcontroller.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);
    }
}

0 个答案:

没有答案