I keep getting an uncaught exception error when there is no image to add from my image array. Here is some of my code:
This is my
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Method:
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
self.photoImage = image;
[self.photoArray addObject:self.photoImage];
//[self.tableView reloadData];
[picker dismissViewControllerAnimated:YES completion:nil];
This is my TableView cell block:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
XYZToDoItem *toDoItem = [self.toDoItems objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont fontWithName:@"Poiret One" size:18];
cell.textLabel.text = toDoItem.itemName;
NSDictionary *dict = [self.tableArray objectAtIndex:indexPath.row];
cell.detailTextLabel.textColor = [UIColor grayColor];
cell.detailTextLabel.text = [dict objectForKey:@"Time"];
//adding blank index and crashing
UIImage *photo = [self.photoArray objectAtIndex:indexPath.row];
cell.imageView.image = photo;
if (toDoItem.completed) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
I did initialize the array in the [View DidLoad] Method.