多个任务并发执行, 完成后在做某个事情
#import "GroupObject.h"
@interface GroupObject() {
// 并发队列
dispatch_queue_t concurrent_queue;
}
// 容器
@property (nonatomic, strong) NSMutableArray *muArray;
@end
@implementation GroupObject
- (instancetype)init {
if (self = [super init]) {
//创建一个并发队列
concurrent_queue = dispatch_queue_create("mutliread_group", DISPATCH_QUEUE_CONCURRENT);
}
return self;
}
- (void)handleGroup {
dispatch_group_t group = dispatch_group_create();
for (NSString *str in _muArray) {
dispatch_group_async(group, concurrent_queue, ^{
NSLog(@"str");
});
}
dispatch_group_notify(group, concurrent_queue, ^{
NSLog(@"end");
});
}
@end