欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

闭包的声明 实现以及调用

程序员文章站 2022-03-29 19:25:44
...

1闭包的声明

 var chooseHouseSourceClosure: (([HouseSoueceEntity])->())? // 已选房源

闭包的实现

 self.chooseHouseSourceClosure?(self.selectedSoueceEntityArray)

闭包的调用

houseSourceVC.chooseHouseSourceClosure = { [weak self] (houses) in
                // 房源选择结束 调用选择房源结束的闭包
                self?.selectedSoueceEntityArray.removeAll()
                for house in houses {
                    self?.selectedSoueceEntityArray.append(house)
 }