Reputation: 1838
I am using from VIP
in my project and when I route user to another scene open the scene twice ,my router is like bellow? if your need more detail say me. Thank's
@objc protocol ListLanguageRoutingLogic
{
func routeToStartPage(segue: UIStoryboardSegue?)
}
protocol LangSelectedDataPassing
{
var dataStore: SelectLanguageDataStore? { get }
}
class RouterSelectLanguage: NSObject, ListLanguageRoutingLogic, LangSelectedDataPassing
{
weak var viewControllerSelectLanguage: ViewControllerSelectLanguage?
var dataStore: SelectLanguageDataStore?
func routeToStartPage(segue: UIStoryboardSegue?) {
print("BBB")
let destinationVC = viewControllerSelectLanguage?.storyboard?.instantiateViewController(withIdentifier: "ViewControllerStartPage") as! ViewControllerStartPage
var destinationDS = destinationVC.router!.dataStore!
passDataToStartPage(source: dataStore!, destination: &destinationDS)
navigateToStartPage(source: viewControllerSelectLanguage!, destination: destinationVC)
}
// MARK: Navigation
func navigateToStartPage(source: ViewControllerSelectLanguage, destination: ViewControllerStartPage)
{
source.show(destination, sender: nil)
}
// MARK: Passing data
func passDataToStartPage(source: SelectLanguageDataStore, destination: inout StartPageDataStore)
{
print("CCC")
let selectedRow = viewControllerSelectLanguage?.tblView.indexPathForSelectedRow?.row
destination.langSelected = source.langs?[selectedRow!]
}
}
And:
Upvotes: 1
Views: 50
Reputation: 1838
Resolved my problem, I edited my source code like bellow and good work now:
@objc protocol ListLanguageRoutingLogic
{
func routeToStartPage(segue: UIStoryboardSegue?)
}
protocol LangSelectedDataPassing
{
var dataStore: SelectLanguageDataStore? { get }
}
class RouterSelectLanguage: NSObject, ListLanguageRoutingLogic, LangSelectedDataPassing
{
weak var viewControllerSL: ViewControllerSelectLanguage?
var dataStore: SelectLanguageDataStore?
func routeToStartPage(segue: UIStoryboardSegue?) {
let destinationVC = segue!.destination as! ViewControllerStartPage
var destinationDS = destinationVC.startPageRouter!.dataStore!
passDataToStartPage(source: dataStore!, destination: &destinationDS)
}
// MARK: Passing data
func passDataToStartPage(source: SelectLanguageDataStore, destination: inout StartPageDataStore)
{
let selectedRow = viewControllerSL?.tblView.indexPathForSelectedRow?.row
destination.langSelected = source.langs?[selectedRow!]
}
}
Upvotes: 1