【发布时间】:2012-06-06 22:35:13
【问题描述】:
我希望我的应用解压缩并处理 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 is null”!我做错什么了..?
【问题讨论】:
标签: ios cocoa-touch zip nskeyedarchiver