Here is my problem :
I have an NSMutableArray *notes
and which the source of my UITableView* _gradesTV
.
I added the method - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
here :
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSLog(@"%ld", (long)indexPath.section);
NSLog(@"%@", notes);
[_gradesTV beginUpdates];
[notes removeObjectAtIndex:indexPath.section];
[_gradesTV deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section]
withRowAnimation:UITableViewRowAnimationFade];
[_gradesTV endUpdates];
NSLog(@"%@", notes);
}
[_gradesTV reloadData];
}
But when i delete an element I get this error :
*** Terminating app due to uncaught exception 'NSRangeException',
reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
But the NSLog I make on the MutableArray show me 3 elements ...
The line removeObjectAtIndex
on the notes (MutableArray) makes my app crash like it was executed twice ...
Thank you for your help ...
if u want to pull the project and try ...
You will have to create grades with the + button then you can try to delete an item on my table view.
When adding a grade the first TextField is a string
, the second one is a double
value, the third one is also a double
value.