Swift3.0 代理传值,属性传值

来源:互联网 发布:淘宝联盟的优惠券在哪 编辑:程序博客网 时间:2024/05/21 16:21

1.代理传值()MapViewController传值

protocol MapViewDelegate : NSObjectProtocol

{

    func selectedAddress(mapViewController:MapViewController,address:String?)

}

weak var delegate:MapViewDelegate?

self.delegate?.selectedAddress(mapViewController:self,address: currentAddress)


2.接收值 AddOrderViewController

mapVC.delegate =self

extension AddOrderViewController:MapViewDelegate{

    func selectedAddress(mapViewController:MapViewController, address:String?) {

        guardlet path = addresselse { return }

        if mapViewController.view.tag ==1 {

            self.source = path

            //nOrder.sourcePlace = path

            let paths = [IndexPath(row:0, section:0)]

            self.tableView.reloadRows(at: paths, with: .automatic)

        }else{

            self.destination = path

            //nOrder.destinationPlace = path

            let paths = [IndexPath(row:1, section:0)]

            self.tableView.reloadRows(at: paths, with: .automatic)

        }

    }

}



0 0
原创粉丝点击