GCD多个接口请求完之后刷新UI

- (void)loadHttpData {


    dispatch_group_t group = dispatch_group_create();


    dispatch_queue_t searialQueue = dispatch_queue_create("com.hmc.www", DISPATCH_QUEUE_SERIAL);


    dispatch_group_enter(group);


    dispatch_group_async(group, searialQueue, ^{

        //网络请求1

        //成功失败 离开组

        dispatch_group_leave(group);


    });


    dispatch_group_enter(group);


    dispatch_group_async(group, searialQueue, ^{

        //网络请求2

        //成功失败 离开组

        dispatch_group_leave(group);


    });


    dispatch_group_enter(group);


    dispatch_group_async(group, searialQueue, ^{

        //网络请求3

        //成功失败 离开组

        dispatch_group_leave(group);


    });


    //三个网络请求结束,更新UI

    dispatch_group_notify(group, searialQueue, ^{


        dispatch_async(dispatch_get_global_queue(0, 0), ^{


            dispatch_async(dispatch_get_main_queue(), ^{


                //更新UI


            });


        });


    });


}

你可能感兴趣的:(GCD多个接口请求完之后刷新UI)