Latest 0.1.1
Homepage https://github.com/matthewcheok/MCAppRouter
License MIT
Platforms ios 7.0, requires ARC
Authors

MCAppRouter License MIT

Badge w/ Version
Badge w/ Platform

URL routing for iOS made simple.

Installation

Add the following to your CocoaPods Podfile

pod 'MCAppRouter'

or clone as a git submodule,

or just copy files in the MCAppRouter folder into your project.

Setting up MCAppRouter

Add URL mappings as follows, preferrably in your App Delegate, specifying parameters prefixed with colon. The parameters are passed to each instance by setting the properties with key paths (See NSKeyValueCoding).

When instantiating from a UIViewController subclass:

[[MCAppRouter sharedInstance] mapRoute:@"color/:view.backgroundColor/" toViewControllerClass:[UIViewController class]];

When instantiating from a storyboard:

[[MCAppRouter sharedInstance] mapRoute:@"/user/:userID/display_name/:userName/" toViewControllerInStoryboardWithName:@"Main" withIdentifer:@"MCDemoViewController"];

Using MCAppRouter

Afterward, retrieve an instance of the required view controller like this:

UIViewController *controller = [[MCAppRouter sharedInstance] viewControllerMatchingRoute:@"/color/#2C99F8/"];

Or push it directly on a UINavigationController:

[self.navigationController pushViewControllerMatchingRoute:@"user/201/display_name/Michael" animated:YES];

Parameters

Parameter values are always assumed to be NSString unless stated otherwise. Currently strings containing colors in hex format are converted to UIColor before being passed to instances. Other suggestions are welcomed.

License

MCAppRouter is under the MIT license.

Latest podspec

{
    "name": "MCAppRouter",
    "version": "0.1.1",
    "platforms": {
        "ios": "7.0"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "URL routing for iOS made simple.",
    "homepage": "https://github.com/matthewcheok/MCAppRouter",
    "authors": {
        "Matthew Cheok": "[email protected]"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/matthewcheok/MCAppRouter.git",
        "branch": "master",
        "tag": "0.1.1"
    },
    "source_files": "MCAppRouter/*.{h,m}",
    "public_header_files": "MCAppRouter/*.h"
}

Pin It on Pinterest

Share This