Pao*_*aJ. 1 objective-c ios ios7 ios8
如何异步解压缩文件?目前我解压缩如下:
[SSZipArchive unzipFileAtPath:strZipFile toDestination:strDestPath];
Run Code Online (Sandbox Code Playgroud)
但这阻止了我的主线程,并且UI没有响应超过10秒.zip文件超过50MB,我在didFinishLaunching的委托中开始下载(以避免长时间闪屏,因为并不总是需要在开头使用该文件.)
使用GCD在后台线程中运行它:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[SSZipArchive unzipFileAtPath:strZipFile toDestination:strDestPath];
});
Run Code Online (Sandbox Code Playgroud)
您可能想通过在主线程中的某个位置调用方法来告诉您的应用已完成解压缩:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[SSZipArchive unzipFileAtPath:strZipFile toDestination:strDestPath];
dispatch_async(dispatch_get_main_queue(), ^{
[someClass finishedUnzippingFile:strDestPath];
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1042 次 |
| 最近记录: |