简化仅仅运行一次的写法

标准的写法


简化后的宏

/**************************************************************/
// 运行一次
#undef  XY_ONCE_BEGIN
#define XY_ONCE_BEGIN( __name ) \
static dispatch_once_t once_##__name; \
dispatch_once( &once_##__name , ^{

#undef  XY_ONCE_END
#define XY_ONCE_END     });

简化后的写法

- (IBAction)clickOnce:(id)sender {
    XY_ONCE_BEGIN(a)
    SHOWMBProgressHUD(@"only show once", nil, nil, NO, 2)
    XY_ONCE_END
}

你可能感兴趣的:(运行)