NSArray *arr = @[1,2,3,3,4,4,2,0]
unsigned c = arr.count;
uint8_t *bytes = (uint8_t*)malloc(sizeof(*bytes) * c);
unsigned i;
for (i = 0; i < c; i++)
{
NSString *str = [arr objectAtIndex:i];
int byte = [str intValue];
bytes[i] = (uint8_t)byte;
}
NSData *fileData = [NSData dataWithBytesNoCopy:bytes length:c freeWhenDone:YES];
[IOS] NSArray to Bytes
最新推荐文章于 2023-03-20 20:17:07 发布