如果我想获得一个变量的 unsafemutablerawpointer。然而,如果不创建副本或缓冲区,那么最好/有效的方法是什么?
下面的例子有效!
var number:UInt = 5
let numberPointer = UnsafeMutableRawPointer(&number)
var pointer:UnsafeMutablePointer<UInt8> = numberPointer.bindMemory(to: UInt8.self, capacity: size)
pointer[0] = 88
print(numberPointer) // 88
然而来自苹果的文档: