能给源码吗?
能给源码吗?
//换行
var str = "你好,playground"
var stra = "你sss好,playground"
var see = "\(str)\n\(stra)"
print(see)
//查找一个字符串在一个字符串中的位置范围
var stringTest = "andy Wangpeng"
stringTest.rangeOfString("Wangpeng")
stringTest.rangeOfString("Wangpeng",options: NSStringCompareOptions.CaseInsensitiveSearch)
stringTest.startIndex
stringTest.endIndex
//查找一个字符串在一个指定区域的位置范围(不常用)
let startIndex:String.Index = stringTest.startIndex.advancedBy(3);
let endIndex:String.Index = stringTest.endIndex.advancedBy(-3)
let strRange = startIndex..<endIndex
stringTest.rangeOfString("Wangpeng",options: NSStringCompareOptions.CaseInsensitiveSearch,range: strRange)
//截取字符串
stringTest.substringWithRange(strRange)
//插入字符串
stringTest.insert("!", atIndex: startIndex)
//删除指定字符串
stringTest.removeAtIndex(startIndex)
stringTest
//替换字符串
stringTest.stringByReplacingCharactersInRange(strRange, withString: "Hello")
//字符串可以用format了
var aa = NSString(format: "sssss%d",22) as String
let login = (true,"慕课女神")
let(islog,_) = login
//元组
var ConnectState = (ResponseCode:404,_:"success",text:"connect to imooc");
ConnectState.0
举报