我希望我的应用程序能够解压缩和处理 zip 文件的内容。
我正在尝试以 Cocoa 的方式做到这一点,而不使用外部库,所以我转向NSKeyedUnarchiver
这里是我的代码:
-(void) unarchive{
NSString *outputDirectory = [[NSHomeDirectory() stringByAppendingString:@"/Documents/"] stringByAppendingString:@"TheNewFolderName/"];
NSLog(@"Output Directory: %@", outputDirectory);
//MyArchive.zip is the filename of the zip file I placed in Xcode
NSData *theArchive = [NSKeyedUnarchiver unarchiveObjectWithFile:@"MyArchive.zip"];
NSError *error;
[theArchive writeToFile:outputDirectory options:NSDataWritingAtomic error:&error];
NSLog(@"theArchive is %@", theArchive);
这将打印“theArchive 为空”!我究竟做错了什么..?