-(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(@"解压失败");
}
}
网友评论