我正在构建一个从zip文件下载一堆数据的应用程序。我下载了zip文件,但想要提取PDF文件的目录。我正在使用SSZipArchive但我的代码无法正常工作。我想我没有正确解压缩它。SSZiparchive简单的unarchiving
我的代码:
[data writeToFile:filePath atomically:YES];
// Unzipping
NSString *destinationPath = [documentsDir stringByAppendingPathComponent:@"catalogus"];;
[SSZipArchive unzipFileAtPath:filePath toDestination:destinationPath];
[[NSUserDefaults standardUserDefaults] setValue:destinationPath forKey:@"catalogus"];
而在另一个视图 - 控制我想打开PDF
NSString *bestand = [[NSUserDefaults standardUserDefaults] valueForKey:@"catalogus"];
ReaderDocument *testdocument = [ReaderDocument withDocumentFilePath:bestand password:phrase];
当我下载的PDF直接(不拉上全部)我的代码工作正常。
您解压缩文件的文件夹和保存的文件夹路径NSUserDefaults的,但随后您再次检索此文件夹路径以使用ReaderDocument打开。 ReaderDocument是不是要求pdf文件路径而不是文件夹路径? –
请检查此:-http://stackoverflow.com/questions/11333399/download-and-unzip-file-in-ios –
是ReaderDocument是要求PDF文件路径,而不是文件夹路径。当我将文件名添加到路径时,它也不会打开。 我添加了代码: NSString * pdfbestand = [destinationPath stringByAppendingString:@“catalogus.pdf”]; [[NSUserDefaults standardUserDefaults] setValue:pdfbestand forKey:@“catalogus”]; 仍然不能正常工作 –