Import UIKit
//swift string
in string//1>swift is a struct with higher performance
//2>nsstring is an OC object with slightly worse performance
//3> String supports direct traversal
of//4>swift provides a seamless conversion of string and nsstring let
str = "Hello World"
//Traversal string for
C in str.characters{
Print (c)
}
//string concatenation
//concatenation between two strings let
str1 = "Hello" let
str2 = "World"
Let STR3 = str1 + str2
//concatenation of strings and other identifiers let
name = ' ZYF ' let-age
= '
height = 1.88 let
info = ' my Name is \ (name), my time is \ (age), my height is \ (height) "
//concatenation string, string formatting let
minent = 2 let
seconds = 8 let
timestring = String (format: "%02d:%02d", Arguments:[minent,seconds])
print (timestring)
// Intercept of the string let
urlstr = "www.zhengyanfeng.com"
//Convert the string type to NSString type let
header = (urlstr as NSString). SUBSTRING (to:3) let
BODY = (urlstr as NSString). Substring (With:nsrange (Location:4, length:12)) let
Afterbod y = (urlstr as NSString). SUBSTRING (from:17)