I'm prettty sure this is safe, though admittedly I'm never 100% certain when to use withMemoryRebound(to:)
and friends. @Andrew_Trick can probably confirm or deny:
import Foundation
var uuid = UUID().uuid
withUnsafeMutablePointer(to: &uuid) { tuplePointer in
tuplePointer.withMemoryRebound(to: UInt8.self, capacity: 1) { pointer in
uuid_generate(pointer)
}
}
(I used uuid_generate
in my example instead of your Obj-C API in order to have a self-contained example for testing.)