Here is the simple code:
var buffer = [UInt8](_data)
var sec_ivs = [UInt8](repeating: 0, count: 8);
memcpy(&sec_ivs + 3, &buffer, 5);
The Xcode stop building the project with the following error:
How can I rewrite this code to make it works again in Xcode 12? This code is working fine in Xcode 11, but Xcode 11 did not support iOS 14 debuging.Thanks for help.
You can pass the address of the (mutable) element storage of an array to a C function with
but that does not work with offsets. Here you need to use
withUnsafeMutableBytes()
to obtain a buffer pointer, so that you can add an offset:Note that the
&
operator is not needed for the second argument ofmemcpy()
because that is a constant pointer argument.A simpler solution would an assignment to a slice of the target array: