I am using a function that takes an UnsafePointer<String>
.
How do I get an UnsafePointer<String>
from a String?
Trying &someString
gives me the error:
'inout String' is not convertible to 'UnsafePointer<String>'
I am using a function that takes an UnsafePointer<String>
.
How do I get an UnsafePointer<String>
from a String?
Trying &someString
gives me the error:
'inout String' is not convertible to 'UnsafePointer<String>'
&someString
creates a CMutablePointer<String>
.
To convert it to an UnsafePointer
, the simplest solution is to call the special function:
withUnsafePointer(&someString) { unsafePointer in
//do something with the unsafePointer
}