URLからダウンロードしているファイルを解凍しようとしています。ダウンロードされたファイルはzip形式です。私はライブラリを使用しました:SSZipArchiveライブラリを持つiPhone解凍コード。現在のコードでは、ダウンロード後にファイルを解凍するために使用されます。しかし、スタンドアロンとしてアプリを実行すると、ログエラーが発生してアプリケーションがクラッシュします。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");
}