我有一个 NSData 对象,其内容是看起来像这样的原始字节:
1e050014 c8d7b452 28f98c72 e95748b9 2801086b e85b07b9 2c010054 01000014
88c9b452 68878a72 e95748b9 2801086b e85707b9 20030154 10050014 a84bb552
c8299a72 e95748b9 2801086b e85307b9 2c010054
我正在尝试将它们按原样放入字符串数组中,但这没有用并返回一个空数组:
NSData* data0 = [NSData dataWithContentsOfFile:str0];//this contains the bytes well
NSMutableArray *array = [NSMutableArray arrayWithCapacity:data0.length];
这也不起作用:
const char* fileBytes = (const char*)[data0 bytes];
for (int i = 0; i < data0.length; i++) {
UInt8 byteFromArray = fileBytes[i];
[array addObject:@(byteFromArray)];
}
如何将原始字节放入字符串数组而不将原始字节解释为字符串?