美文网首页
SSZipArchive 使用

SSZipArchive 使用

作者: 小福8090 | 来源:发表于2024-05-07 15:36 被阅读0次

-(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(@"解压失败");

        }

}

相关文章

网友评论

      本文标题:SSZipArchive 使用

      本文链接:https://www.haomeiwen.com/subject/idzrfjtx.html