I am looking a better way to convert a hex string to an array of UnsafePointer. here is my current code:
let pointer: UnsafePointer<Int8>? = NSString(string: "d0c6a560de2e60b6ac55386defefdf93b0c907290c2ad1b4dbd3338186bfdc68").utf8String
// or
let pointer: UnsafePointer<Int8>? = NSString(string: key).utf8String
let length = NSString(string: key).length
var res = blsSecretKeySetHexStr(&sec, pointer, length)
I'm porting a C++ class to Swift and this class methods blsSecretKeySetHexStr and blsPublicKeyGetHexStr require UnsafePointer and UnsafeMutablePointer as input.
You can find useful informations about
UnsafePointerusage here.First if you have want to pass a pointer to a string to a function accepting an
UnsafePointer<Int8>you can simply do :or
or
if you need an
UnsafeMutablePointer:or