swift string转怎么做

请问下,swift string转怎么做
最新回答
操守

2024-04-25 05:04:09

var str = "hello, world"

str.utf8.startIndex
var byteArray = [Byte]()
for char in str.utf8{
byteArray += char
}
println(byteArray)

可以参阅Swift官方文档:
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html