在ios上使用zlib时出错

时间:2014-01-02 18:06:03

标签: ios zlib

这是我用来从压缩资源文件中读取并将解压缩数据写入文档目录中的文件的代码:

- (void)setupPFile
{
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString* passwordsFile = [documentsPath stringByAppendingPathComponent:@"p.txt"];
        BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:passwordsFile];

        if (!fileExists) {
            NSString *resourceDictPass = DICTIONARY_FILE;
            NSString *resourcePath = [[NSBundle mainBundle] pathForResource:resourceDictPass ofType:@"gz"];
            NSData *fileCompressedData= [NSData dataWithContentsOfFile:resourcePath];
            NSError *error = nil;
            [fileCompressedData writeInflatedToFile:passwordsFile error:&error];
            if (error) {
                NSLog(@"error uncompressing passwords file");
                return;
            }
        }

    });
}

这是我得到的错误:

Printing description of error:
Error Domain=se.bitba.ZlibErrorDomain Code=2 "The operation couldn’t be completed. (se.bitba.ZlibErrorDomain error 2.)"

我正在使用我在这里推荐的NSData + zlib类别。 如何调试?

0 个答案:

没有答案