一、创建一个 Swift File
二、定义相关接口
如:
//返回订单
typealias SendChooseOrder = (_ order:ChooseOrderReulstModel) -> Void
//刷新界面
typealias SendRefresh = () -> Void
三、接口使用
如:
//定义引用接口
var sendChooseOrder:SendChooseOrder?
//使用接口以及数据使用
controller.sendChooseOrder = { (order:ChooseOrderReulstModel) -> Void in
self.orderNumber = order.InvNumber
self.orderId = "\(order.InvId ?? 0)"
self.cellHead?.btnOrderText.setTitle(self.orderNumber, for: .normal)
self.cellHead?.tvProductName.text = "产品名称:\(order.ProductName ?? "")"
self.cellHead?.tvProductBatch.text = "产品批次:\(order.BatchNO ?? "")"
}
//接口-刷新数据
var sendRefresh:SendRefresh?
//刷新数据
controller.sendRefresh = {()->Void in
self.getData(deleteList: true)
}
四、说明
可以用在界面间响应,也可以用在tableView cell响应
//完整刷新代码展示
let row = (indexPath as NSIndexPath).row
let controller = UIStoryboard(name: "TwoMain",
bundle:nil).instantiateViewController(withIdentifier:
"OldHalfOrderDetailsController") as! OldHalfOrderDetailsController
controller.sendRefresh = {()->Void in
self.getData(deleteList: true)
}
self.present(controller, animated: true, completion: nil)