ios - How to Custom group notify for blocks of functions -
asynchronous block called in function, add these multiple functions group,process results of blocks when block execute completely.is there common , smart method implement?
dispatch_group_notify ,completionblock
dispatch_group_t _blocktaskgroup; ..... if (!_blocktaskgroup) { _blocktaskgroup = dispatch_group_create(); } dispatch_group_notify(_blocktaskgroup, dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{ nslog(@"finally!"); }); .... dispatch_group_enter(_blocktaskgroup); [xxxxx computeinbackground:xx completion:^{ nslog(@"1 done"); dispatch_group_leave(group); }]; // dispatch_group_enter(_blocktaskgroup); [xxxxx computeinbackground:xx completion:^{ nslog(@"2 done"); dispatch_group_leave(_blocktaskgroup); }]; // dispatch_group_enter(_blocktaskgroup); [xxxxx computeinbackground:xx completion:^{ nslog(@"3 done"); dispatch_group_leave(_blocktaskgroup); }];
Comments
Post a Comment