typealias 类型定义总结
- 给已有类型重新定义名称,方便代码阅读
- 定义闭包,类似oc的block 定义
//eg:1.已有类型的重新命名
typealias Address = CGPoint
let point: CGPoint = CGPoint(x: 0,y: 0)
//等价于
let point: Address = CGPoint(x: 0,y: 0)
闭包定义
typealias successCallback = (_ code: String, _ message: String) -> Void
var callBack: successCallback?
self.callBack!(code: "0",message: "ok")
网友评论