//weak宏定义
#define HJY_Weak(controller) __weak typeof(controller) weakSelf = controller
//GCD - 异步并行队列
#define HJYDISPATCH_GROUP_ASYNC(group_async_block,group_notify_block) dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);\
dispatch_group_t group = dispatch_group_create();\
dispatch_group_async(group, queue, group_async_block);\
dispatch_group_notify(group, queue, ^{\
dispatch_async(dispatch_get_main_queue(), group_notify_block);\
})\
//GCD - 一次性执行
#define HJYDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//GCD - 异步主线程
#define HJYDISPATCH_MAIN_ASYNC(main_queue_block) dispatch_async(dispatch_get_main_queue(), main_queue_block)
//GCD - 异步子线程
#define HJYDISPATCH_GLOBAL_QUEUE_ASYNC(global_queue_block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), global_queue_block)
//使用案例
//HJYDISPATCH_GLOBAL_QUEUE_ASYNC(^{});
关于GCD的一些宏定义
最新推荐文章于 2022-08-07 17:18:33 发布