Solution and Question


#1

I came up with a solution very similar to what others have done. It basically seems to work:

-(void)deleteTask:(id)sender { int rowISelected = [self.taskTable selectedRow]; [self.tasks removeObject:self.tasks[rowISelected]]; [self.taskTable reloadData]; [self updateChangeCount:NSChangeDone]; }

There’s one issue, though. It will delete items with the same name, even if only one is selected. So if bread, milk, juice, bread are in my list and I delete the first instance of bread, both will be deleted.

My best guess was that somehow they were both being classified as the same row, but I haven’t found anything in the documentation to support this.

Does anyone know?


#2

It seems that you are getting the selectedRow, then using that to get the item in the array (which is a string of text); removeObject looks for all occurrences of the item (string of text) you give it and removes it. Since you have the selectedRow, you can pass that to your array and remove just that one item using removeObjectAtIndex (uses a NSUInteger).

NSUInteger rowISelected = [self.taskTable selectedRow]; [self.tasks removeObjectAtIndex:rowIsSelected];