Latest 1.0.1
Homepage https://github.com/srv7/CleanStroyBoard
License MIT
Platforms ios 8.0, requires ARC
Authors

What’s this

CleanStoryBoard is very simple, it saves you from instantiating storyboards using string literals and you can leverage autocomplete feature to get storyboard instances. No scope for typos !

Installation

pod 'CleanStoryBoard'

Usage

  1. define an enum, e.g. Storyboards

    enum Storyboards: String {
            case Main
            case Home
            case Feed
            case Account
        }
  2. extension the struct Storyboard, add static properties, just like below:

    extension Storyboard { 
        static let Main = Storyboard(rawValue: Storyboards.Main.rawValue)
        static let Home = Storyboard(rawValue: Storyboards.Home.rawValue) static let Feed = Storyboard(rawValue: Storyboards.Feed.rawValue)
        static let Account = Storyboard(rawValue: "Account") // not recommended
    }

    as you see, you can create a Account by user String literals Account, but it’s not recommended, using the enum is high recommanded.

  3. assign identifiers to ViewControllers in your storyBoards, just be same as Class Name, then you can initialize your ViewController as below:
    let n1 = HomeNavigationController.instance(from: Storyboard.Home)
    let n2 = FeedNavigationController.instance(from: .Feed)
    let n3 = AccountNavigationController.instance(from: .Account)

License

CleanStoryBoard is released under an MIT license. See License.md for more information.

Latest podspec

{
    "name": "CleanStoryBoard",
    "version": "1.0.1",
    "summary": "Clean Story Board",
    "description": "Clean the StoryBoard",
    "homepage": "https://github.com/srv7/CleanStroyBoard",
    "license": "MIT",
    "authors": {
        "liubo": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/srv7/CleanStroyBoard.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "Source",
        "Source/*.swift"
    ],
    "requires_arc": true,
    "swift_version": "4.1"
}

Pin It on Pinterest

Share This