Closed zhaozzq closed 10 months ago
代码如下:
NSOperationQueue *queue = [[NSOperationQueue alloc] init]; queue.maxConcurrentOperationCount = 3; __block BOOL hasError = NO; for ( ... ) { [queue addOperationWithBlock:^{ OSSPutObjectRequest * put = [OSSPutObjectRequest new]; put.bucketName = APPENV; put.objectKey = imgName; put.uploadingData = UIImageJPEGRepresentation(image, 0.1); OSSTask * putTask = [client putObject:put]; [putTask waitUntilFinished]; if (putTask.error) { hasError = YES; } }]; } [queue waitUntilAllOperationsAreFinished];
外层套了 dispatch_async(dispatch_get_global_queue(0, 0), ^{ })好了
dispatch_async(dispatch_get_global_queue(0, 0), ^{ })
代码如下: