Latest 0.1.6
Homepage https://github.com/dhrebeniuk/SegueWithCompletion
License LICENSE
Platforms ios 8.0, requires ARC
Authors

SegueWithCompletion is UIViewController extension that provides ability perform segue and clarify setup viewcontroller parameters without override prepareForSegue method.

Installation

Via CocoaPods:

pod 'SegueWithCompletion'

Storyboard Usage

Present UIViewContreoller

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()
    }
}

Present UIViewContreoller with UINavigationController

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()
    })
}

Compatibility/Restrictions

  • iOS8+ only

Latest podspec

{
    "name": "SegueWithCompletion",
    "version": "0.1.6",
    "summary": "Extension for UIViewController for ability perform segue with completion handler for avoid override prepareForSegue method.",
    "description": "Extension for UIViewController for ability perform segue with completion handler fortavoid override prepareForSegue method.",
    "homepage": "https://github.com/dhrebeniuk/SegueWithCompletion",
    "license": "LICENSE",
    "authors": {
        "Dmytro Hrebeniuk": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/dhrebeniuk/SegueWithCompletion.git",
        "tag": "0.1.6"
    },
    "source_files": "UIViewControllerSegueExtension.swift",
    "requires_arc": true,
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This