我想解壓縮正在通過URL下載的文件。下載的文件是zip格式。我已經使用庫:iPhone Unzip code它具有SSZipArchive庫。它在當前代碼中用於解壓下載的文件。但是,當我將應用程序作爲獨立應用程序運行時,應用程序因提供日誌錯誤而崩潰:example.app未能及時啓動。我不確定我是否可以使用這個庫,或者是否有任何其他庫已經過嘗試,測試並在設備上運行。在設備上解壓縮文件由於超時而崩潰
- (void)viewDidLoad {
[super viewDidLoad];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/ZipFiles.zip", directoryPath];
NSString* updateURL = @"http://www.example.com/test.php?id=11";
NSData* updateData = [NSData dataWithContentsOfURL: [NSURL URLWithString: updateURL] ];
[fileManager createFileAtPath:filePath contents:updateData attributes:nil];
/* SSZipArchive is a free API built on ZipArchive to unzip the files. Header file is passed in this class.*/
[SSZipArchive unzipFileAtPath:filePath toDestination:directoryPath];
NSLog(@"Finished unzipping database");
}