Latest 0.1.4
Homepage https://github.com/RogyMD/SwiftyStoryboard
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

A framework that helps you to operate with UIStoryboard and it’s components.

Swift version
Pod Version
GitHub license

Requirements

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate SwiftyStoryboard into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'SwiftyStoryboard'
end

Then, run the following command:

$ pod install

Usage

Create a StoryboardType

import SwiftyStoryboard

// Enum example of `StoryboardType`.
enum AppStoryboard: String, StoryboardType {
  case main = "Main"
}

// Struct example of `StoryboardType`.
struct AppStoryboardStruct: RawRepresentable, StoryboardType {
  typealias RawValue = String

  let rawValue: String

  init(rawValue: String) {
    self.rawValue = rawValue
  }

  static var main = AppStoryboardStruct(rawValue: "Main")
}

Create a StoryboardSceneType

import SwiftyStoryboard

class ViewController: UIViewController {}

extension ViewController: StoryboardSceneType {
  class var mainStoryboard: AppStoryboard {
    return .main
  }
}

StoryboardSceneType provides default class property scene. Feel free to use it to initialize an ViewController instance.

let vc = ViewController.scene

Create a SeguePerformer

import SwiftyStoryboard

class ViewController: UIViewController {}

extension ViewController: SeguePerformer {
  // Define `SegueType` as nested enum `Segue`
  typealias SegueType = Segue

  // Nested enum `Segue` with defined `UIStoryboardSegue` identifier as implicit `rawValue`
  enum Segue: String, StoryboardSegueType {
    case second
  }
}

Perform segues easier.

perform(segue: .second)

Handle segues in more swifty way.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    super.prepare(for: segue, sender: sender)

    // `Segue` should be initialized with `UIStoryboardSegue` instance.
    if let segue = Segue(segue) {
      NSLog("Segue('(segue.segueID)') was performed.")
    }
}

License

SwiftyStoryboard is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "SwiftyStoryboard",
    "version": "0.1.4",
    "summary": "A framework that helps you to operate with UIStoryboard and itu2019s components.",
    "homepage": "https://github.com/RogyMD/SwiftyStoryboard",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "Igor Bidiniuc": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/RogyMD/SwiftyStoryboard.git",
        "tag": "0.1.4"
    },
    "source_files": [
        "SwiftyStoryboard",
        "SwiftyStoryboard/SwiftyStoryboard/*.swift"
    ],
    "frameworks": "UIKit",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This