NSData 与 std::vector 转换

- (void)convert {
    // vector 转 NSData
    std::vector 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 result(bytes, bytes + data.length);
}

你可能感兴趣的:(NSData 与 std::vector 转换)