I have my array:
self.colorNames = [[NSArray alloc]
initWithObjects:@\"Red\", @\"Green\",
@\"Blue\", @\"Indigo\", @\"Violet\", nil];
I\'ve
This is what worked for me
-(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if (editingStyle == UITableViewCellEditingStyleDelete){
Comment *comment = [self.commentArray objectAtIndex:indexPath.row];
dispatch_async(kBgQueue, ^{
if([self.thePost deleteCommentForCommentId:comment.commentId]){
if (indexPath.row < self.commentArray.count) {
[self.commentArray removeObjectAtIndex:indexPath.row];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.tvComments reloadData];
});
}
});
}
[self.tvComments reloadData];
}
Swift 4 Version :
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .destructive, title: "delete") { (action, indexPath) in
// delete item at indexPath
}
return [delete]
}