I’ve used the sdk standard code for deleting however it crashes once I press the delete button.
I am using this code
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[tableFavoritesData arrayWithObject:indexPath] withRowAnimation:YES];
}
}
I tried with both NSMutableArray instead of tableFavoritesData however nothing works.
Well, basically what you want to do is:
Correct code should probably look like that:
EDIT: I didn’t notice another error.
You need to specify the type of animation, not just pass YES or NO. For example: UITableViewRowAnimationFade. Check out possible UITableViewRowAnimation values here.
EDIT 2: For the comment below (comment formatting suck):
Check out NSNotificationCenter in the docs, especially addObserver:selector:name:object: and postNotificationName:object: methods.
In your other view controller (probably viewDidLoad method):
and while deleting the row:
Just remember that you need to remove observer from notification center when you dealloc the other UIViewController:
Hope I didn’t make much errors, I don’t have access to XCode atm.