I'm trying to convert some old ObjC code to Swift, I haven't done a lot with Swift regarding Pointers.
Original ObjC/C code:
unsigned char myId[6];
memcpy(myId, packet.header->m1, 6);
Original C Struct:
typedef struct {
unsigned char m1[6];
unsigned char m2[6];
} __attribute__((__packed__)) HeaderStruct;
My tried Swift code, not working:
var myId = [CUnsignedChar](repeating: 0, count: 6)
var headerStruct: UnsafePointer<HeaderStruct> = packet!.header()
memcpy(&myId, headerStruct.pointee.m1, 6)
The error regarding headerStruct.pointee.m1
Cannot convert value of type '(UInt8, UInt8, UInt8, UInt8, UInt8, UInt8)' to expected argument type 'UnsafeRawPointer?'
I assume I need the base address (headerStruct) and add the offset for the m1, but how do I do that?