PhiceDev PhiceDev - 1 month ago 22
Swift Question

IOHIDDeviceSetReport method doesn't accept UnsafeRawPointer type in Swift 3

IOHIDDeviceSetReport method doesn't accept UnsafeRawPointer type
the method signature is :

IOHIDDeviceSetReport(<#T##device: IOHIDDevice##IOHIDDevice#>, <#T##reportType: IOHIDReportType##IOHIDReportType#>, <#T##reportID: CFIndex##CFIndex#>, <#T##report: UnsafePointer<UInt8>##UnsafePointer<UInt8>#>, <#T##reportLength: CFIndex##CFIndex#>)


thta allows to give as input only a UnsafePointer type, but in swift 3 there I can ony use UnsafeRawPointer type.
Does anybody have any idea how to get a UnsafeRawPointer from UnsafeRawPointer?

Answer

There are several methods for migrating an UnsafeRawPointer to UnsafePointer. The one I've used the most has been:

UnsafePointer.withMemoryRebound(to:capacity:_)

You should be able to use the above, or one of the other methods mentioned in the following page to do what you need:

https://swift.org/migration-guide/se-0107-migrate.html