IOHIDDeviceSetReport 方法不接受 UnsafeRawPointer 类型 方法签名是:
IOHIDDeviceSetReport(<#T##device: IOHIDDevice##IOHIDDevice#>, <#T##reportType: IOHIDReportType##IOHIDReportType#>, <#T##reportID: CFIndex##CFIndex#>, <#T##report: UnsafePointer<UInt8>##UnsafePointer<UInt8>#>, <#T##reportLength: CFIndex##CFIndex#>)
thta 只允许将 UnsafePointer 类型作为输入,但在 swift 3 中我只能使用 UnsafeRawPointer 类型。 有人知道如何从 UnsafeRawPointer 获取 UnsafeRawPointer 吗?
最佳答案
有几种方法可以将 UnsafeRawPointer 迁移到 UnsafePointer。我用得最多的是:
UnsafePointer.withMemoryRebound(to:capacity:_)
您应该能够使用上述方法或下一页中提到的其他方法之一来完成您需要的操作:
关于swift - IOHIDDeviceSetReport 方法不接受 Swift 3 中的 UnsafeRawPointer 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40340037/