I'm trying to convert this source code :
BluetoothDeviceAddress *deviceAddress = malloc(sizeof(BluetoothDeviceAddress));
to Swift, which gives me :
let deviceAddress: BluetoothDeviceAddress = malloc(sizeof(BluetoothDeviceAddress))
But, I found that in Swift 3/4, sizeof is not used anymore but this is not my error, Xcode returns :
"Cannot convert value of type 'UnsafeMutableRawPointer!' to specified type 'BluetoothDeviceAddress'"
I tried changing to malloc(MemoryLayout<BluetoothDeviceAddress>.size) but still the same error.
EDIT:
As proposed in the comments by MartinR, I tried changing to let deviceAddress = BluetoothDeviceAddress()
but then when I want to initialize an IOBluetoothDevice, I still get an error (selectedDevice is a var for IOBluetoothDevice):
self.selectedDevice = IOBluetoothDevice(address: deviceAddress)
Error : Cannot convert value of type 'BluetoothDeviceAddress' to expected argument type 'UnsafePointer!'
Best,
Antoine