0
私はtryブロックにコードブロックを配置したプロジェクトを開発しています。例外が発生した正確なポイントを取得するには?
このブロックには、imageViewに画像を割り当てるための5つのステートメントが含まれています(画像フォルダに画像を追加する5つの画像ビューがあります)。リソースフォルダにイメージがない場合は、catchブロックにジャンプします。
私は画像にnil
を割り当てることができるように、例外が発生している5つのうち正確なステートメントを知りたかったのです。
@try {
if (indexPath.row%2==0) {
cell.bookImageView1.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+0].titleImage;
cell.bookImageView2.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+1].titleImage;
cell.bookImageView3.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+2].titleImage;
cell.bookImageView4.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+3].titleImage;
cell.bookImageView5.image=nil;
}else {
cell.bookImageView1.image=nil;
cell.bookImageView2.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+0].titleImage;
cell.bookImageView3.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+1].titleImage;
cell.bookImageView4.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+2].titleImage;
cell.bookImageView5.image=[[KitabooBookListDataSource sharedDataSource] bookAtIndex:(indexPath.row*4)+3].titleImage;
}
}
@catch (NSException *e) {
NSLog(@"catch block");
NSLog(@"array of exception %@",[e callStackReturnAddresses]);
//NSMutableArray *catchArray=[[NSMutableArray alloc] initWithArray:[e callStackReturnAddresses]];
//[[catchArray lastObject] ]=nil;
}
どのような例外が発生しますか?答えはそれに依存します。 – Yuji