iOS 壓縮與解壓縮的原理
阿新 • • 發佈:2019-01-04
使用第三方框架SSZipArchive解壓縮;(匯入框架檔案,在link binary with libraries中新增lib.tbd;)
-(void)zip{
//壓縮
[SSZipArchivecreateZipFileAtPath:@"/Users/apple/Desktop/222.zip"withContentsOfDirectory:@"/Users/apple/Desktop/11111"];
}
//從網路下載zip包,解壓縮
- (void)getZIP{
NSURL *url = [NSURLURLWithString:@"http://127.0.0.1/1.zip"];
[[[NSURLSession
//location zip包下載到本地的路徑
NSLog(@"%@",location.path);
//解壓
[SSZipArchiveunzipFileAtPath:location.pathtoDestination:@"/Users/apple/Desktop/11111"];
}] resume];
}