我正在使用流行的类 SSZipArchive 来解压缩文件,具体来说是这个方法:
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler
而且我正在更新内部块中的两个 uilabels 文本,它们都已分配,它们的两个文本之前都已更改,当我打印 uilabels 的内容时,文本已更新但屏幕没有更新,我有说当我完成将 zip 下载到委托方法时会加载此方法。
我的代码:
- (void)downloadManager:(id)sender finishedDownload:(ANDownload *)download {
if ( [[NSFileManager defaultManager] fileExistsAtPath:download.storeFile] ) {
NSLog(@"Download exists");
[self.labelStep setText:CustomLocalizedString(@"ZIP_DECOMPRESSING_MSG", nil)];
[SSZipArchive unzipFileAtPath:download.storeFile toDestination:self.saveFolderPath progressHandler:^(NSString *entry, unz_file_info zipInfo, long entryNumber, long total) {
//Your main thread code goes in here
NSString * labelProgressText = [NSString stringWithFormat:@"%ld / %ld", entryNumber, total];
self.labelProgress.text = labelProgressText;
} completionHandler:^(NSString *path, BOOL succeeded, NSError *error) {
NSLog(@"Succeeded %d in path: %@", succeeded, path);
if(succeeded){
.....