Use of unresolved identifier 'sizeof' BLE error

Hi All,


I am trying to make a BLE Xcode program that controls an LED, and I came across a program that was already made but in Xcode 8. When I converted it to Xcode 9, I got rid of all the errors except this one: Use of unresolved identifier 'sizeof'. Here is the code in which the error takes place:


func writeLedCharacteristic(_ val: Int8)

{

var val = val

let ns = Data(bytes: UnsafePointer<UInt8>(&val), count: sizeof(Int8))

capsenseLedBoard!.writeValue(ns, for: ledCharacteristic, type: CBCharacteristicWriteType.withResponse)

}


(The 'sizeof' is underlined in red and seems to be the cause of the error.)


Do you know what could have gone wrong from the change from Xcode 8 to Xcode 9? What is the correct code to fix this error?


Any help would be appreciated.


Thanks,

Andrew Collins