Objective-Zip, MiniZip 및 ZLib 드래그를이 링크 http://code.google.com/p/objective-zip/downloads/list (Objective-zip)에서 프로젝트로 드래그하여 끕니다. ZipFile.h, ZipException.h, FileInZipInfo.h, ZipWriteStream.h, ZipReadStream.h, zlib.h
사용이 코드 : 파일을 가져옵니다. 아래 참조 :
NSString *stringPath1 = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0]];
NSString *FileName=[stringPath1 stringByAppendingPathComponent:@"Your file name"];
NSString *stringPath=[stringPath1 stringByAppendingPathComponent:[@"Your file name" stringByAppendingFormat:@".zip"]];
NSArray *files = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:FileName error:&error];
ZipFile *zipFile = [[ZipFile alloc]initWithFileName:stringPath mode:ZipFileModeCreate];
for(int i = 0;i<files.count;i++){
id myArrayElement = [files objectAtIndex:i];
NSLog(@"add %@", myArrayElement);
NSString *path = [FileName stringByAppendingPathComponent:myArrayElement];
NSDictionary *attributes = [[NSFileManager defaultManager]attributesOfItemAtPath:path error:&error];
NSDate *Date = [attributes objectForKey:NSFileCreationDate];
ZipWriteStream *streem = [zipFile writeFileInZipWithName:myArrayElement fileDate:Date compressionLevel:ZipCompressionLevelBest];
NSData *data = [NSData dataWithContentsOfFile:path];
[streem writeData:data];
[streem finishedWriting];
}
[zipFile close];
ARC를 파일 단위로 해제 할 수 있다는 것을 알고 계시겠습니까? 따라서 ARC가 아닌 코드가있는 경우 ARC 프로젝트에서이 코드를 사용할 수 있습니다. ARC는 전부 또는 일부가 아닙니다. 이것은 파일 당 컴파일러 옵션입니다. http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project –
그리고 더 명확히하기 위해, 그러한 빌드를하는 Xcode 프로젝트가 있다면 Objective-C 라이브러리 및 ARC가 아닌 라이브러리를 사용하면 해당 프로젝트를 프로젝트에 포함하고 ARC 여부와 관계없이 라이브러리를 사용할 수 있습니다. –
오, 아니, 나는 그 사실을 몰랐다. –