string*Swift's string type is seamlessly bridged with the Foundation NSString class*the strings in the OC language are also terminated with a, Swift is not*The string in OC is an object, and Swift uses string as a struct, which is more efficient and supports traversal attention* Swift's string type is a value type. If you create a new string, then it is a constant, variable assignment operation, or a function/when passed in a method, a value copy is made. In any case, a new copy of the existing string value is created and the new copy is passed or assigned to let STR="SC\0lnj" forChinchstr.characters {print (ch)}//Stitchingvar str1 ="SSC"var str2="NX"str1+=STR2STR1//interpolated ValuesLet name ="SSC" let Age= toLet result="name = \ (name), age = \ (age)"//Formatting//01.png//02.png//...//10.png forIinch 0...5{let name= String (format:"%02d.png", arguments: [i]) print (name)}//InterceptLet STR3 ="com.baidu.www"//Intercept XMG//Note: Methods for intercepting strings in Swift, receiving parameters that are not the same as in OC//early, for everyone to develop convenient, proposed conversion to nsstring after interception//ConversionLet STR4 = Str3 asNsstringlet result2= Str4.substringfromindex (Ten)//The . StartIndex in the swift string that is used to get the position of the first character in a string//The . EndIndex in the swift string that gets the position of the last string ' Next ' in the stringLet RESULT3 = Str3.substringfromindex (Str3.endIndex.advancedBy (-3)) Let Result4= Str3.substringfromindex (Str3.startIndex.advancedBy (Ten))
Swift learns-----strings