嗨,大家好我想壓縮NSData這是一個文本文件,使用https://github.com/nicklockwood/GZIP多行文本文件。一切工作正常,除了當我在另一個設備上對文件進行gunzip時,我在得到的txt文件的每行的開頭都會出現奇怪的字符,如¤¤AccelerometerEvent,1.0,1.0,1.0,143957782
。GZIP NSData iOS 9.0
的代碼非常簡單:
NSData *compressedData = [dataToZip gzippedDataWithCompressionLevel:1.0];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[compressedData writeToFile:[documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.gz", [self getLogArchiveFileName]]] atomically:YES];
以前我是用另一種方法來生成與zlib的壓縮文件,但後來我在服務器端的問題,以解壓縮,然後我決定去GZIP 。這不是一個通信問題,它會破壞文件,因爲如果我將文件發送到服務器,並且如果使用Xcode將它們複製到我的計算機上,它就會發生。你有什麼想法如何解決這個問題?謝謝
你是如何創建'dataToZip'? –