【发布时间】:2018-02-15 23:53:20
【问题描述】:
我正在使用 AFNetworking 库下载一个压缩文件夹,文件正在下载,但是当我尝试解压缩该 zip 文件夹时,它没有打开。在 mac 机器上,它也不会通过双击和存档实用程序进行提取。
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File downloaded to: %@", filePath);
[SSZipArchive unzipFileAtPath:[filePath path] toDestination: [[filePath path] stringByDeletingLastPathComponent]];
}];
【问题讨论】:
-
SSZipArchive会抛出什么样的错误? -
为目录设置属性失败:2017-09-07 10_06_53.zip/.storage。
-
错误域=NSCocoaErrorDomain Code=4 "文件“.storage”不存在。" UserInfo={NSFilePath=2017-09-07 10_06_53.zip/.storage, NSUnderlyingError=0x600000053ce0 {Error Domain=NSPOSIXErrorDomain Code=2 "没有这样的文件或目录"}}
-
你的目标路径是什么?我认为问题在于目标路径可能是错误的。
-
我的源和目的路径相同,文档目录。
标签: ios objective-c macos unzip ssziparchive