Problem deleting row


Hi, I am having trouble with the method that deletes rows. I have copied it like in the book:

1 -(void)tableView:(UITableView *)tableView
2 commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
3 forRowAtIndexPath:(NSIndexPath *)indexPath{
5 if(editingStyle == UITableViewCellEditingStyleDelete){
7 NSArray *items = [[BNRItemStore sharedStore] allItems];
8 BNRItem *item = items[indexPath.row];
9 [[BNRItemStore sharedStore] removeItem:item];
10 [tableView deleteRowsAtIndexPaths:indexPath
11 withRowAnimation:UITableViewRowAnimationFade];
12 }
13 }

First of all, I get the following warning on both lines 9 and 10, with the parameters “item” and “indexPath” underlined:

Sending ‘BNRItem *__strong’ to parameter of incompatible type ‘id _Nonnull’

This warning goes away if I insert ‘(id)’ in front of such parameters.

Then the program crashes anyway with the exception:

‘NSInvalidArgumentException’, reason: '-[NSIndexPath count]: unrecognized selector sent to instance

Can anyone help me with this?

Many thanks