Ios ZipArchive阻塞主线程

Ios ZipArchive阻塞主线程,ios,objective-c,zip,Ios,Objective C,Zip,当使用ZipArchive解压包时,它似乎阻塞了主线程。zip文件中大约有283个文件。我把它放在背景线上,但它似乎没有帮助 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, (unsigned long) NULL), ^{ [self tryUnzipFile:fileName inContentPackage:contentPackage]; }); - (void)try

当使用ZipArchive解压包时,它似乎阻塞了主线程。zip文件中大约有283个文件。我把它放在背景线上,但它似乎没有帮助

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, (unsigned long) NULL), ^{
    [self tryUnzipFile:fileName inContentPackage:contentPackage];
  });

- (void)tryUnzipFile:(NSString*)fileName inContentPackage:(MKContentPackage*)contentPackage {

  @synchronized (self) {
    NSString *filePath = [contentPackage zipFilePathForFile:fileName];
      BOOL unzipSucceeded = [self unzipFile:filePath toFolder:contentPackage.unzipFolder];
      if (unzipSucceeded) {
        [self excludeFromBackup:contentPackage.downloadFolder];
        NSLog(@"Content: Unzipping Content Package: %@ FileName: %@", contentPackage.identifier, fileName);
      }   
  }
}

- (BOOL)unzipFile:(NSString*)zipFilePath toFolder:(NSString*)zipFolder {
  ZipArchive *zipArchive = [[ZipArchive alloc] init];
  NSString* unzipPath = [NSObject documentFolderFrom:zipFolder fileName:@""];

  // Do the unzipping
  [zipArchive UnzipOpenFile:zipFilePath];
  BOOL unzipped = [zipArchive UnzipFileTo:unzipPath overWrite:YES];
  [zipArchive UnzipCloseFile];

  if (unzipped) {
    [self removeZipPackage:zipFilePath];
  }
  return unzipped;
}
上面的代码在解压时将屏幕冻结约5秒。我以为把它放在背景线程上会有帮助,但事实并非如此。任何帮助都会很棒

 @synchronized (self) {
    NSString *filePath = [contentPackage zipFilePathForFile:fileName];
      BOOL unzipSucceeded = [self unzipFile:filePath toFolder:contentPackage.unzipFolder];
      if (unzipSucceeded) {
        [self excludeFromBackup:contentPackage.downloadFolder];
        NSLog(@"Content: Unzipping Content Package: %@ FileName: %@", contentPackage.identifier, fileName);
      }   
  }

如果这个上下文中的“自我”是你的VIEW /VIEW控制器,你应该考虑在同步块中使用另一个变量。

你可以在没有“@同步”的情况下测试它吗?这没什么帮助。它仍然冻结了UIC,实际上这似乎改善了很多。谢谢