求解,GCD信号量相关的问题

上传2张图片后,再提交信息到服务器,但是如果uploadImage这个是单例的话信号量就永远在等待了!不知道为什么。

直接贴代码:

dispatch_group_t group=dispatch_group_create();

dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

[self uploadImage1];

});

dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

[self uploadImage2];

});

dispatch_group_notify(group,dispatch_get_main_queue(),^{

[self uploadToServer];

});

其中一个uploadImage是,其中:RKUploadImage是一个单例模式的图片上传工具:

dispatch_semaphore_t semaphore=dispatch_semaphore_create(0);

NSString *filename=[NSString stringWithFormat:@"%@_1.png",[RKMineUtils getTimeAndRandom]];

[[RKUploadImage shareUploadImage] uploadImage:img1 name:filename success:^(NSString *imageURL, NSString *imagerURLBase64) {

//计数器+1

imgUrl1=imagerURLBase64;

NSLog(@"上传第一张图片成功");

} failure:^(NSError *error) {

dispatch_semaphore_signal(semaphore);

[self.navigationController.view makeToast:@"身份证上传失败,请重试!"];

[self hideHUD];

}];

//如果是0则等待;

dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

求大神指导!

你可能感兴趣的:(求解,GCD信号量相关的问题)