- #import "ViewController.h"
- #import "SSZipArchive.h"
-
- @interface ViewController ()
-
- @end
-
- @implementation ViewController
-
-
-
-
-
-
-
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
- NSString *str = @"http://localhost/images.zip";
- str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL *url = [NSURL URLWithString:str];
-
-
- [[[NSURLSession sharedSession] downloadTaskWithURL:url completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
- NSLog(@"文件的路径%@",location.path);
-
-
- NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject];
-
-
-
- [SSZipArchive unzipFileAtPath:location.path toDestination:caches];
-
- }] resume];
-
- }
-
- @end
用到的第三方解压缩框架:SSZipArchive
下载地址:https://github.com/samsoffes/ssziparchive
注意:需要引入libz.dylib框架