I have an Int
which I want to copy to a pointer of type UnsafeMutablePointer<Int32>?
I tried to cast it to Data and then copy it, but the copy function param is of type UnsafeMutablePointer<UInt8>
This is what I've tried:
var sizePointer: UnsafeMutablePointer<Int32>?
var numOfBytes = 100
var sizeData = Data(bytes: &(numOfBytes), count: MemoryLayout<Int>.size)
//What's now? How to copy it to the pointer?
//sizeData.copyBytes(to: size, count: MemoryLayout<Int>.size) not working
Edit:
I have the following function, that gets a pointer. I need to copy the int to that address.
func f(pointer: UnsafeMutablePointer<Int32>?) {
var numOfBytes = 100
//copy numOfBytes to the pointer's address
}