SegueWithCompletion is UIViewController extension that provides ability perform segue and clarify setup viewcontroller parameters without override prepareForSegue method.
Via CocoaPods:
pod 'SegueWithCompletion'
Change perform your's segues from this:
func openFooScreen() {
self.performSegue(withIdentifier: "fooSegue", sender: nil);
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let fooController = segue.destination as? FooViewController, segue.identifier == "fooSegue" {
fooController.settings = Settings()
}
}
To this:
func openFooScreen() {
self.perform(segue: "fooSegue") { (fooController: FooViewController) in
fooController.settings = Settings()
}
}
Change perform your's segues from this:
func openBarScreen() {
self.performSegue(withIdentifier: "barSegue", sender: nil);
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let barNavigationController = segue.destination as? UINavigationController, segue.identifier == "fooSegue" {
if let barController = barNavigationController.topViewController as? BarViewController {
barController.settings = Settings()
}
}
}
To this:
func openBarScreen() {
self.performWithNavigationController(segue: "barSegue") { (barController: BarViewController) in
barController.settings = Settings()
})
}
- iOS8+ only