我正在尝试将一些objective-c 代码(mac)移植到c++ 代码(win)。但是,我有一个问题。在 Mac 上,我的数据以 NSMutableData 对象的形式出现,在 Windows 上,它以 uint8_t 数组的形式出现。我需要将我的 uint8_t 数据转换为 NSMutableData 中相同类型的数据。帮助!
//on the mac
foo(NSMutableData* received)
{
void* data = malloc([received length]);
memcpy(data, [received mutableBytes], [received length]);
bar(data);
}
//on windows
foo(const boost::shared_array<uint8_t>& received)
{
void* data = ... //magic needs to happen here
bar(data);
}