浏览代码

improve requestImageDataForAsset

Marino Faggiana 7 年之前
父节点
当前提交
78343e3911
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      iOSClient/Utility/NCRequestAsset.m

+ 7 - 0
iOSClient/Utility/NCRequestAsset.m

@@ -123,6 +123,8 @@
         
         @autoreleasepool {
             
+            dispatch_semaphore_t semaphoreGroup = dispatch_semaphore_create(0);
+            
             PHImageRequestOptions *options = [PHImageRequestOptions new];
             options.synchronous = NO;
             
@@ -157,7 +159,12 @@
                             [self.delegate upload:fileName serverUrl:serverUrl cryptated:cryptated template:NO onlyPlist:NO fileNameTemplate:nil assetLocalIdentifier:assetLocalIdentifier session:session taskStatus:taskStatus selector:selector selectorPost:selectorPost errorCode:errorCode delegate:delegate];
                     }
                 }
+                
+                dispatch_semaphore_signal(semaphoreGroup);
             }];
+            
+            while (dispatch_semaphore_wait(semaphoreGroup, DISPATCH_TIME_NOW))
+                [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
         }
     }
 }