Tôi đã sử dụng ZipArchive với thành công trong quá khứ.
Nó khá ligthweight và dễ sử dụng, hỗ trợ bảo vệ bằng mật khẩu, nhiều tệp bên trong ZIP, cũng như nén & giải nén.
Việc sử dụng cơ bản là:
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"ZipFileName" ofType:@"zip"];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@"xxxxxx"];
[zipArchive UnzipFileTo:{pathToDirectory} overWrite:YES];
[zipArchive UnzipCloseFile];
[zipArchive release];
này là dành cho giải nén một thư mục/tập tin. Để nén các thư mục cũng dễ dàng như nhau. Để nén một tệp (hoặc bộ lọc thức ăn)
BOOL ret = [zip CreateZipFile2:l_zipfile];
// OR
BOOL ret = [zip CreateZipFile2:l_zipfile Password:@"your password"]; //
//if the Password is empty, will get the same effect as [zip CreateZipFile2:l_zipfile];
ret = [zip addFileToZip:l_photo newname:@"photo.jpg"];
if(![zip CloseZipFile2])
{
// error handler here
}
[zip release];
Tôi cũng đã nghe nói về ObjectiveC-Zip.
Nguồn
2011-11-16 10:40:54
Cảm ơn .. Nó đã hoạt động :) – Yogi
Yogi tôi đang đối mặt với cùng một tình huống.u có thể chia sẻ mã của bạn – thavasidurai
Tôi nghĩ rằng anh ta đã sử dụng đoạn mã trên @thavasidurai – Robin