I am developing a project in which I placed a block of code in a try block.
The block contains 5 statements in order to assign a image to a imageView (I have 5 imageviews to which I am adding images from resource folder). The flow jumps to catch block if there is no image in the resource folder.
I wanted to know the exact statement out of the five where the exception is getting raised so that I can assign the image a nil
.
@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;
}