Browse Source

improve requestImageDataForAsset

Marino Faggiana 7 years ago
parent
commit
78343e3911
1 changed files with 7 additions and 0 deletions
  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]];
         }
     }
 }