清理swift如何将数据传递回viewController

清理swift如何将数据传递回viewController,swift,swift3,Swift,Swift3,当我弹出到navigationController时,我无法接收数据,例如,我们应该可以查看控制器 class ListBillPaymentFavoriteRouter: NSObject, ListBillPaymentFavoriteRoutingLogic, ListBillPaymentFavoriteDataPassing { weak var viewController: ListBillPaymentFavoriteViewController? var dat

当我弹出到navigationController时,我无法接收数据,例如,我们应该可以查看控制器

class ListBillPaymentFavoriteRouter: NSObject, ListBillPaymentFavoriteRoutingLogic, ListBillPaymentFavoriteDataPassing {
    weak var viewController: ListBillPaymentFavoriteViewController?
    var dataStore: ListBillPaymentFavoriteDataStore?

    // MARK: Routing

    func routeToBillPaymentInput() {
        let destinationVC = BillPaymentInputViewController.instantiate()
        var destinationDS =  destinationVC.router!.dataStore!
        passDataToBillPaymentInput(source: dataStore!, destination: &destinationDS)
        navigationToBillPaymentInput(source: viewController!, destination: destinationVC)
    }

    // MARK: Navigation

    func navigationToBillPaymentInput(source: ListBillPaymentFavoriteViewController, destination: BillPaymentInputViewController) {
        source.navigationController?.pop_FromLeftMoveToRight()
    }

    // MARK: Passing data

    func passDataToBillPaymentInput(source: ListBillPaymentFavoriteDataStore, destination: inout BillPaymentInputDataStore) {
        destination.testTest = "Yessssss"
    }


}
根本


}

使用
委派
通知
如果我不想使用委派,我该怎么做?@PuChaisirikul iOS使用委派是常见的方式。但是您可以使用回调而不是使用swift闭包来传递可能重复的数据
func routeToBillPaymentInput() {
    let index = viewController!.navigationController!.viewControllers.count - 2
    let destinationVC = viewController?.navigationController?.viewControllers[index] as! BillPaymentInputViewController
    var destinationDS =  destinationVC.router!.dataStore!
    passDataToBillPaymentInput(source: dataStore!, destination: &destinationDS)
    navigationToBillPaymentInput(source: viewController!, destination: destinationVC)
}
class ListBillPaymentFavoriteRouter: NSObject, ListBillPaymentFavoriteRoutingLogic, ListBillPaymentFavoriteDataPassing {
weak var viewController: ListBillPaymentFavoriteViewController?
var dataStore: ListBillPaymentFavoriteDataStore?

// MARK: Routing

func routeToBillPaymentInput() {
    let index = viewController!.navigationController!.viewControllers.count - 2
    let destinationVC = viewController?.navigationController?.viewControllers[index] as! BillPaymentInputViewController
    var destinationDS =  destinationVC.router!.dataStore!
    passDataToBillPaymentInput(source: dataStore!, destination: &destinationDS)
    navigationToBillPaymentInput(source: viewController!, destination: destinationVC)
}

// MARK: Navigation

func navigationToBillPaymentInput(source: ListBillPaymentFavoriteViewController, destination: BillPaymentInputViewController) {
    source.navigationController?.popViewController(animated: true)
}

// MARK: Passing data

func passDataToBillPaymentInput(source: ListBillPaymentFavoriteDataStore, destination: inout BillPaymentInputDataStore) {
    destination.testTest = "Yessssss"

}