1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| let s1: String = "dsfdsf"
for char in s1 { print(char) }
let s2 = "dasdfds" let s3 = s1 + s2 print(s3)
let length: Int = s3.count print("长度:\(length)")
let rs1 = s3.isEmpty print("是否为空:\(rs1)")
let s4: String = "fsdfdsfsd" let s5 = s4.uppercased() print("s4:\(s4)") print("s5:\(s5)")
let s7: String = "dasd3243232423sfsfdsf13"
let s8: Substring = s7.prefix(4) let label = UILabel.init() label.text = String.init(s8)
let s9: String = s7 + s8
let s10: Substring = s7.suffix(5) print("s10:\(s10)")
let offset4Index: String.Index = s7.index(s7.startIndex, offsetBy: 4) let dest14Index = s7.index(offset4Index, offsetBy: 10) let s11: Substring = s7[offset4Index..<dest14Index] print("s11:\(s11)")
var s12: String = "sfdsfds" s12.removeLast() print("s12:\(s12)"
|