StoryboardEnum 0.2.0

StoryboardEnum 0.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Matteo Crippa.



StoryboardEnum

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

First of all make sure that inside your AppDelegate func didFinishLaunchingWithOptions we have this snippet:

window = UIWindow(frame:UIScreen.mainScreen().bounds)

Then you have to create a new enum of type StoryboardEnum.

import StoryboardEnum

enum Storyboard: StoryboardEnum {

    case Main

    var story: StoryboardVC {
        return StoryboardVC(inWindow: UIApplication.sharedApplication().windows.first!)
    }

    var vc: UIViewController? {
        switch self {
            case Main:
            return story.getVC(fromStoryboard: "Main", withIdentifier: "Main")
        }
    }

}

Finally you have only to call wherever you want to present the view controller:

Storyboard.Name.show()

you can even show the vc embedded in a navigation using:

Storyboard.Name.show(inNavigation: true)

IMPORTANT If you plan to omit the identifier of the VC, please check that there is at least one VC set to be Initial view controller in your storyboard to avoid the app to crash.

Extra

I’ve added a nice way to embed a VC in navigationController, using embedInNavigation() func you will received your navigation w/ the view inside.

Installation

StoryboardEnum is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "StoryboardEnum"

Author

Matteo Crippa, @ghego20

License

StoryboardEnum is available under the MIT license. See the LICENSE file for more info.