Swift 闭包反向传值
Swift中闭包反向传值
1.第二控制器申明一个闭包类型
typealias BackBlock = (String) -> Void
2.第二控制器定义一个变量
var BackBlockClousure : BackBlock?
3.第一控制器实现回调
let VC = segue.destination as! DetailsViewController VC.BackBlockClousure = { (backStr:String) -> Void in NSLog(backStr, "") }
4.第二控制器传值
self.BackBlockClousure!("反向传值" + area.name)