我收到此錯誤Objective-C的警告,未聲明的標識符的使用 '新'
使用未聲明的標識符的 '新'
在這行代碼
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對象,但是這讓我無法繼續前進。
任何幫助將不勝感激。
這種方法工作,是文件轉換爲zip格式 –