定義字符串
let opratoin : String="ddffcc"
遍歷字符串
for c in opratoin.characters{
print(c)
}
字符串的拼接
let str1 ="哥"
let str2 ="didi "
var str3 ="aaa"
str3 = str1 + str2
字符串和其他字符之間的拼接
let name ="why"
let age =18
let height =1.88
let info ="my name is\(name) ,my age is\(age) ,my height is\(height)"
拼接字符串字符串的格式化
let min =2
let second =8
let timeStr =String(format:"%d:%d", [min,second]);
//字符串的截取
let urlString ="www.520.it.com"
將string轉(zhuǎn)換NSString
let header = (urlString as NSString).substring(to:3)
let middle = (urlString as NSString).substring(with:NSMakeRange(4,4))
let footer = (urlString as NSString).substring(from:10)