i use an api in swift that provide me a function to send data to some destination ,the function has a parameter of type UnsafeMutablePointer < astruct >. astruct is a structure and has three variable, first one is the data , that is of type UnsafePointer < Uint8 > , second one is bytes to send of type uint32 and destination is third one.
now the question is how to work with this function, how to give these variables to call the function and init the struct.
what i have as data to send is an array [0xf0,0xf7,0x03,0x01]. what should i do now? can't accept the array as the data in astruct, it should be UnsafePointer, i read the documentation on UnsafePointer but i dont get it that well, can some one please help me??
// swift api
func senddata (_ req: UnsafeMutablePointer < astruct >) -> OSStatus
struct astruct {
var data : UnsafePointer < UInt8 >
var bytestosend : UInt32
var destination : destination
}
var array : [UInt8] = [0xf0,0xf7,0x03,0x01]
var st = astruct(data : array , bytestosend : UInt32(array.count) , destination: dest)
senddata ( st )
how to do the unsafe pointe thing?