一、字符串用法
- 数字转字符串的用法
- 通过
String()转化为字符串并以+拼接let num = 88 let str = "this is a num " let result = str + String(num) - 通过
\()的方式来转化为字符串let num = 88 let result = "this is a num \(num)"
- 使用三个双引号
"""来为字符串表示输入多行内容let num = 88 let result = """ this is multiple line "中间可以随意加引号 \(num)" 感觉功能类似MarkDown的代码高亮``` """
二、数组字典的用法
- 数组字典可变和不可变是根据
let和var控制var emptyArray = [String]() emptyArray.append("1") let dic = [String : String]() //error dicM1["1"] = "2" - 因Swift面向协议的思想,数组和字典内存储的内容不再局限于对象了
let array = [1, 2, 3] var dicM = [Int:Int]() dicM[1] = 1000
三、其他不同
- 自己创建的文件不再需要通过
Import导入 系统自动已经帮你导入了,你只需要保证不会重名