我有一个问题需要处理NSMutableData
.
我定义了一个NSMutableData *receivedData
,并试图将几个NSData*
数据复制到receivedData
.我刚刚调用[receivedData appendData:data]
,但似乎没有复制数据:
.... NSLog(@"get data! Received %d bytes of data",[data length]); // output is not zero, say 1231. [receivedData appendData:data]; NSLog(@"after append! length is %d bytes of data",[receivedData length]); // showing zero
谢谢.
检查是否receivedData == nil
.如果是这样,那么您可能忘记初始化它.例如:
receivedData = [[NSMutableData alloc] init];
然后在您不再需要它时释放它:
[receivedData release]; receivedData = nil;