删除方法被调用的次数太多了。为什么?

时间:2014-07-16 13:36:14

标签: ios objective-c

我的应用程序允许您长按某个项目,然后选择删除作为选项。当您按下删除时,会弹出一个警告视图,并要求您确认是否要删除它。当我选择是时它会删除两个项目,而不只是一个。使用断点我知道它会循环遍历该方法多次。两次准确

这是代码

- (void)delete:(id)sender
{
MYSDynamicAlertView *alertView = [MYSDynamicAlertView new];

alertView.alertTitle = @"Are you sure you want to delete that?";
alertView.message = @"You won't be able to retrieve the message once its deleted.";

[alertView setTitle:@"Delete" dismissBlock:^{
    FCIMessageCell *cell               = self.cellShowingMenuController;
    NSIndexPath *ip                    = [self.tableView indexPathForCell:cell];
    FHChatInteraction *chatInteraction = self.visitor.chatInteractions[ip.row];
    [[FHSChatSocket sharedSocket] sendDeleteChatInteraction:chatInteraction];
    [chatInteraction destroy];    }
          direction:MYSDynamicAlertViewDirectionUp];

[alertView setTitle:@"Cancel" dismissBlock:^{
} direction:MYSDynamicAlertViewDirectionDown];


[alertView show];

}

那我该如何修复呢?为什么要调用它两次而不是一次?

1 个答案:

答案 0 :(得分:2)

MYSDynamicAlertView中有一个错误导致该块被调用两次。我刚修好并提交了拉取请求。

在此期间,您可以找到固定代码here