Latest 1.0
Homepage https://github.com/ramy-kfoury/SwiftRouter
License MIT
Platforms ios 8.0
Authors ,

Carthage compatible

A Swift Router Implementation.

Requirements

  • iOS 8+
  • Xcode 6.3+

Installation

You can use Carthage:

github "ramy-kfoury/SwiftRouter"

or CocoaPods:

pod 'SwiftMessageBar'

Usage

To use the router, first create an instance of it in your AppDelegate class, and then update the following method:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
        return router.routeURL(url)
    }

Adding a route requires only a route parameter, and a closure to implement your action

addRoute(yourCustomRoute) { [unowned self] parameters in
            // present a view controller or anything you like to do when this route is detected
        }

The closure returns to you the parsed parameters, which can be either path parameters or query parameters. Here’s an example:

route = scheme://host/path/parameter1/value1?parameter2=value2
parameters = [
"parameter1": "value1"
"parameter2": "value2"
]

To call a route from anywhere in your app:

UIApplication.sharedApplication().openURL(URL)

TODO

  • Investigate using NSURLComponents for better parsing of routes

Licence

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

Latest podspec

{
    "name": "SwiftRouter",
    "version": "1.0",
    "summary": "A Swift Router",
    "description": "                   A longer description of SwiftMessageBar in Markdown format.nn                   * Think: Why did you write this? What is the focus? What does it do?n                   * CocoaPods will be using this to generate tags, and improve search results.n                   * Try to keep it short, snappy and to the point.n                   * Finally, don't worry about the indent, CocoaPods strips it!n",
    "homepage": "https://github.com/ramy-kfoury/SwiftRouter",
    "license": "MIT",
    "authors": {
        "Ramy Kfoury": "https://github.com/ramy-kfoury/",
        "Jan Gorman": "https://github.com/JanGorman/"
    },
    "social_media_url": "http://twitter.com/ramy_kfoury",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/ramy-kfoury/SwiftRouter.git",
        "tag": "1.0"
    },
    "source_files": "SwiftRouter/SwiftRouter/*.swift"
}

Pin It on Pinterest

Share This