Is there a way I could convert a String to an UnsafeMutablePointer<UInt8>
in Swift language, avoiding data loss?
Asked
Active
Viewed 1,496 times
-1

Martin R
- 529,903
- 94
- 1,240
- 1,382

ch_studend
- 91
- 2
- 10
-
What exactly do you need the pointer to? Do you want to *modify* the string via the pointer or is it for read-only access? – Martin R Jul 25 '16 at 11:12
-
please share what have you tried already – Özgür Ersil Jul 25 '16 at 11:16
-
Possible duplicate of [UnsafeMutablePointer
from String in Swift](http://stackoverflow.com/questions/27876179/unsafemutablepointerint8-from-string-in-swift). – Martin R Jul 25 '16 at 11:17 -
I've managed to handle it, thank's anyway! – ch_studend Jul 26 '16 at 06:30
1 Answers
0
let s = "83"
var i: UInt8 = UInt8.init(s)!
let up: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>.init(&i)

itlijunjie
- 61
- 1
- 4