I am tasked with converting some functions from Objective-C to Swift. We are using a C file to transfer files to a bluetooth device. Here is the Objective-C code that needs to be converted.
From the Objective-C file:
NSString *room_name = filename;
NSData* bytes = [room_name dataUsingEncoding:NSUTF8StringEncoding];
UInt8 buff_name[bytes.length+1];
memcpy(buff_name, [room_name UTF8String],[room_name lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1);
I am stuck on memcpy for Swift and am not sure this is the safest method for what we are trying to do. Thank you.