- (void)convert {
// vector 转 NSData
std::vector<uint8_t> ori = {3, 1, 2, 3, 5, 7};
NSData* data = [[NSData alloc] initWithBytes:ori.data() length:ori.size()];
const uint8_t* bytes = (const uint8_t*)data.bytes;
// NSData 转 vector
std::vector<uint8_t> result(bytes, bytes + data.length);
}
网友评论