1

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];

}

4

1 に答える 1

0

私は一貫性のない行動を取り始めたので、ここでさらに多くの投稿を読むことに戻りました。

プロジェクトの分析後に見つかったすべてのエラーを修正するための提案に従って、問題を解決しました。「初期化中に「ペアリング」に保存された値が読み取られない」など、一見無関係に見えるいくつかのエラーを修正しました。これで問題が直接解決したかどうかはわかりませんが、プロセスのどこかで問題が解決しました。

ご参考までに

viewDidLoadメソッドの後、viewWillAppearメソッドの前にアプリがクラッシュしていました。ステップバイステップのデバッグにより、私は何も知らないマシンコードにたどり着きました。

- (void)viewDidLoad
{
   [super viewDidLoad];

   NSLog(@"selectedArray count is %i",[selectedArray count]);
   NSLog(@"selectedArray name is %@",selectedArrayName);
   NSLog(@"checkedRowMonth is %i",[[HDLogOnStore sharedStore]checkedRowMonth]);

}

- (void) viewWillAppear:(BOOL)animated
{
   [super viewWillAppear:animated];
}
于 2013-01-27T16:35:11.143 に答える