문제

I need to create a big table to csv file and compress it.

I can create the csv file like this: Xcode - Create csv/spreadsheet file

It is possible compress it with GZIP?

Thanks for all.

Best regards.

도움이 되었습니까?

해결책

I recommend you use SSZipArchive: https://github.com/soffes/ssziparchive

Then you can do:

NSString *content = @"1,2,3"
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"somefile.zip"];
SSZipArchive *zip = [[SSZipArchive alloc] initWithPath:path];
[zip open];
[zip writeData:[content dataUsingEncoding:NSUTF8StringEncoding] filename:@"data.csv"];
[zip close];

That will produce a zip file named "somefile.zip" in the temporary directory, containing one file inside named "data.csv"

다른 팁

The easiest way is to probably not use a standard copy build phase to move the file into place, but instead use shell script build phase to copy the file and then compress it in place with gzip.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top