我曾经用于NSMutableData
合并字节数组
NSMutableData *payload;
payload = [[NSMutableData alloc] init];
[payload appendBytes:CFBridgingRetain((cm.msgBytes)) length:[cm.msgBytes length]];
NSString *cmdata = [[NSString alloc] initWithData:[payload mutableBytes] encoding:NSUTF8StringEncoding];
我想继续添加payload
直到完成
cmdata 始终为零
因为initWithData
需要NSData
所以我将字节转换为NSData
但结果仍然相同
NSData *bytesData = [NSData dataWithBytes:[payload mutableBytes] length:[payload length]];
NSString *cmdata = [[NSString alloc] initWithData:bytesData encoding:NSUTF8StringEncoding];