iOS-回调的基本使用
2016-09-23 本文已影响0人
Mn_Su
一.在SettingItem.h中声明
typedef void (^MJSettingItemOption)();
@property (nonatomic, copy) SettingItemOption option;
二.在别的类中使用使用
SettingItem *update = [SettingArrowItem itemWithIcon:@"MoreUpdate" title:@"检查新版本"];
update.option = ^{
// 弹框提示
[MBProgressHUD showMessage:@"正在拼命检查中....."];
#warning 发送网络请求
// 几秒后消失
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 移除HUD
[MBProgressHUD hideHUD];
// 提醒有没有新版本
[MBProgressHUD showError:@"没有新版本"];
});
};