我使用的函数需要一个UnsafePointer<String>
如何从字符串中获取UnsafePointer<String>
尝试&someString时出错:

'inout String' is not convertible to 'UnsafePointer<String>'

最佳答案

&someString创建一个CMutablePointer<String>
要将其转换为UnsafePointer,最简单的解决方案是调用特殊函数:

withUnsafePointer(&someString) { unsafePointer in
    //do something with the unsafePointer
}

关于swift - 'inout String'不能转换为'UnsafePointer <String>',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24172234/

10-10 20:44