我收到此错误
使用未声明的标识符“新”
在这行代码上
Byte* decompressedBytes = new Byte[COMPRESSION_BLOCK];
这是我出现这行代码的方法。
// Returns the decompressed version if the zlib compressed input data or nil if there was an error
+ (NSData*) dataByDecompressingData:(NSData*)data{
Byte* bytes = (Byte*)[data bytes];
NSInteger len = [data length];
NSMutableData *decompressedData = [[NSMutableData alloc] initWithCapacity:COMPRESSION_BLOCK];
Byte* decompressedBytes = new Byte[COMPRESSION_BLOCK];
z_stream stream;
int err;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
stream.next_in = bytes;
err = inflateInit(&stream);
CHECK_ERR(err, @"inflateInit");
while (true) {
stream.avail_in = len - stream.total_in;
stream.next_out = decompressedBytes;
stream.avail_out = COMPRESSION_BLOCK;
err = inflate(&stream, Z_NO_FLUSH);
[decompressedData appendBytes:decompressedBytes length:(stream.total_out-[decompressedData length])];
if(err == Z_STREAM_END)
break;
CHECK_ERR(err, @"inflate");
}
err = inflateEnd(&stream);
CHECK_ERR(err, @"inflateEnd");
delete[] decompressedBytes;
return decompressedData;
}
我不确定为什么会这样。这段代码来自ObjectiveZlib并且已经通读了好几次,我并没有尝试在我自己的代码中使用它来解压缩 zlib NSData 对象,但是这阻止了我的进步。
任何帮助将不胜感激。