NSData.data vs Data.withUnsafeBytes

It's undefined behaviour. It might work, either by design or accident, or it could be really slow or stop working in the next OS update or hardware revision. Just avoid it.

1 Like

if it works by design it's quite pity to see the man-years(?) of hardware designers cumulative time wasted for a feature that they considered needed and that we end up not using, because it might not work in the future!

UnsafeMutableRawPointer.copyMemory(from:byteCount:) simply forwards its parameters to memmove as (essentially) memmove(baseAddress, from, byteCount).

1 Like
Terms of Service

Privacy Policy

Cookie Policy