IOS_多个异步请求同步执行

dispatch_group_t group = dispatch_group_create();

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
    
    
    dispatch_group_async(group, queue, ^{
        
        //异步操作
        dispatch_semaphore_signal(semaphore);
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        
    });

 //异步操作完成之后执行的方法
 dispatch_group_notify(group, queue, ^{
        
        
        
  });

你可能感兴趣的:(IOS_多个异步请求同步执行)