我想將一些Objective-C代碼(mac)移植到C++代碼(win)。但是,我有一個問題。在Mac上,我的數據以NSMutableData對象的形式出現,在Windows上以uint8_t數組的形式出現。我需要將我的uint8_t數據轉換爲NSMutableData中相同類型的數據。幫幫我!需要幫助將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);
}