Aaron挖了个坑 2017-12-07 07:59 采纳率: 0%
浏览 2042
已采纳

ios开发,无参数无返回值的block代码段在方法中怎么声明

封装了提示框的方法如下,但是这个block是有返回值的,如果要没有返回值应该怎么改?还有点击确定之后是否只需要confirmAction();就可以了?在线等大神

 - (void)showAlert:(id)sendTarget message:(NSString *)messageText comfirm:(void (^)(id object))comfirmAction{

    UIAlertController *showAlert = [UIAlertController alertControllerWithTitle:@"" message:messageText preferredStyle:UIAlertControllerStyleAlert];

    [showAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
        confirmAction(nil);
    }]];

    //弹出提示框;
    [sendTarget presentViewController:showAlert animated:true completion:nil];

}
  • 写回答

2条回答 默认 最新

  • Nov_J 2017-12-08 05:43
    关注

    直接这样不就可以了么

      - (void)showAlert:(id)sendTarget message:(NSString *)messageText comfirm:(void (^)())comfirmAction{
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已采纳回答 10月28日