promise 类似于 async awit 异步请求等待的操作,可以避免网络请求一层一层嵌套
swift属性
存储属性
- 类似于成员变量这个概念
- 存储在实例的内存中
- 结构体,类可以定义存储属性
- 枚举不可以定义存储属性
计算属性
- 本质就是方法
- 不占用实例的内存
- 枚举,结构体,类都可以定义计算属性
inout 的本质总结
- 如果实参有物理内存地址,且没有设置属性观察器
直接将实参的内存地址传入函数(实参进行引用传递) - 如果实参是计算属性或者设置了属性观察器
采取了Copy In Copy Out 的做法
1 调用该函数时,先复制实参的值,产生副本【get】
2 将副本的内存地址传入函数(副本进行引用传递),在函数内部可以修改副本的值
3 函数返回后,将副本的值覆盖实参的值【set】
//输入输出函数的本质是引用传递 :即把内存地址传递
fun test(_ num : inout Int) {
num = 20
}
类型属性

method

mutating

@discardableResult

下标(subscript)









属性观察器



final

多态


父类指针指向子类对象
网友评论