HDLogOnViewControllerは、HDLogOnViewControllerのtableview:didSelectRowAtIndexPathメソッドのHDDomicileViewControllerに2つの変数を渡します。
HDDomicileViewControllerのviewDidLoadメソッドの後に、EXCBADACCESSエラーでアプリがクラッシュします。変数はHDDomicileViewControllerで正しく検証されます。
助けを借りずにゾンビを有効にしました。Guard Mallocを有効にすると、アプリは正常に実行されます。XCodeの出力ビューには、エラーの原因が示されていません。ここで多くのEXCBADACCESSスレッドを調査し、インスタンス変数の代わりにプロパティを使用してみました。ifelseifの代わりに4つのifステートメントを使用しました。これを行うと、アプリは1つのifステートメントだけで正常に実行されますが、複数のステートメントでクラッシュします。また、4つのifステートメントを使用すると、それぞれのステートメントをコメント化するとクラッシュし、問題がif条件にあるように見えます。
エラーの原因を特定するにはどうすればよいですか?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellLabel = [NSString stringWithString:[[[HDLogOnStore sharedStore] cellTitleLabels] objectAtIndex:[indexPath row]]];
if ([cellLabel isEqualToString:@"Domicile"]) {
tableViewArray = [[HDLogOnStore sharedStore] domiciles];
tableViewArrayName = @"domiciles";
NSLog(@"indexPath row is %i", [indexPath row]);
NSLog(@"array name is %@", [[[HDLogOnStore sharedStore] cellTitleLabels] objectAtIndex:[indexPath row]]);
}
else if ([cellLabel isEqualToString:@"Position"]) {
tableViewArray = [[HDLogOnStore sharedStore] positions];
tableViewArrayName = @"positions";
NSLog(@"indexPath row is %i", [indexPath row]);
NSLog(@"array name is %@", [[[HDLogOnStore sharedStore] cellTitleLabels] objectAtIndex:[indexPath row]]);
}
else if ([cellLabel isEqualToString:@"BidRound"]) {
tableViewArray = [[HDLogOnStore sharedStore] bidRounds];
tableViewArrayName = @"bidRounds";
NSLog(@"indexPath row is %i", [indexPath row]);
NSLog(@"array name is %@", [[[HDLogOnStore sharedStore] cellTitleLabels] objectAtIndex:[indexPath row]]);
}
else if ([cellLabel isEqualToString:@"Month"]) {
tableViewArray = [[HDLogOnStore sharedStore] months];
tableViewArrayName = @"months";
NSLog(@"indexPath row is %i", [indexPath row]);
NSLog(@"array name is %@", [[[HDLogOnStore sharedStore] cellTitleLabels] objectAtIndex:[indexPath row]]);
}
HDDomicileViewController *domicileViewController = [[HDDomicileViewController alloc]init];
[domicileViewController setSelectedArray:tableViewArray];
[domicileViewController setSelectedArrayName:tableViewArrayName];
[self.navigationController pushViewController:domicileViewController animated:YES];
}