Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

segue_handler_plugin

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

segue_handler_plugin

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

WillowTreeSegueHandler

Better segue handling in Swift

Installation

Gemfile

gem "segue_handler_plugin"

Podfile

plugin 'segue_handler_plugin'
pod 'WillowTreeSegueHandler'

Build Phases Add a run script phase before the "Compile Sources" phase, with the following:

bundle exec pod --no-ansi --silent generate-segue-handlers $PROJECT_DIR $PROJECT_NAME

Build it once, then add the SegueExtensions.swift file to your project and build again.

Usage

Segues with identifiers will be pulled out into nested enums in extensions on your view controllers, written to SegueExtensions.swift.

Example generated code, assuming A and B are view controllers connected with from A to B via the segue with identifier "ToB".

extension A: SegueHandler {
    enum SegueIdentifier: String {
        case ToB
    }

    enum ToSegueDestination: SegueDestination {
        case ToB(B)

        init?(identifier: SegueIdentifier, destination: UIViewController) {
            switch identifier {
            case .ToB:
                guard let vc = destination as? B else { return nil }
                self = ToB(vc)
            }
        }
    }
}

These can be used in your view controller like so:

func pushManually() {
    performSegue(.ToB, sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    switch segueFromStoryboardSegue(segue) {
    case .ToB(let b):
        b.prepare(dependency: "injected from a")
    }
}

See the enclosed Example application for a working demo.

WillowTree is Hiring!

Want to write amazing tvOS apps? Want to write amazing iOS apps? Check out our openings!

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc