SSZipArchive 使用

-(void)unZip

{

    NSString *caches=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject];

    NSString *unzipPath = [[NSBundle mainBundle] pathForResource:@"dddddd" ofType:@"zip"];

    NSString *desPath=[caches stringByAppendingPathComponent:@"unzip"];

    UIImageView *image=[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

    image.backgroundColor=[UIColor redColor];

    [self.viewaddSubview:image];


    BOOLsuccess =  [SSZipArchive unzipFileAtPath:unzipPath toDestination:desPath overwrite:YES password:nil error:nil];;

    if(success) {

        NSLog(@"解压成功");

        NSString*unzippedFilePath = [desPathstringByAppendingPathComponent:@"dddddd.png"];

        NSData*fileData = [NSDatadataWithContentsOfFile:unzippedFilePath];

        dispatch_async(dispatch_get_main_queue(), ^{

                image.image= [UIImageimageWithData:fileData];

            });

        }else{

            NSLog(@"解压失败");

        }


}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS开发系列--网络开发 概览 大部分应用程序都或多或少会牵扯到网络开发,例如说新浪微博、微信等,这些应用本身可...
    lichengjin阅读 3,721评论 2 7
  • 一、数据持久化概述 数据持久化就是数据的永久存储。其本质是将数据保存为文件,存到程序的沙盒中。 1、数据持久化的方...
    lilinjianshu阅读 642评论 0 1
  • // //ViewController.m //Created by S u p e r m a n on 201...
    路灯下的黑猫H阅读 205评论 0 0
  • 1.自定义控件 a.继承某个控件 b.重写initWithFrame方法可以设置一些它的属性 c.在layouts...
    圍繞的城阅读 3,484评论 2 4
  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,217评论 30 472