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

A URL Router who parse url use regex express for iOS. Inspired by HHRouter

Usage

Warm Up

Map URL patterns to a block.

GMRouter *router = [GMRouter shared];
GMRouterBlock block = ^(NSDictionary *params) {
    NSLog(@"%@", params[@"uid"]);
    NSLog(@"%@", params[@"pid"]);
};

[router map:@"/gemini/[uid]/[pid]" toBlock:block];

What we get next

Get the block and parameters when request a url

GMRouterBlock newBlock = [router matchBlock:@"/gemini/123/23423?hello=world"];
newBlock(nil);

We will get the params in block.

How about Controller

GMRouter *router = [GMRouter shared];
[router map:@"/q/[questionId]" toControllerClass:[UIViewController class]];
UIViewController *controller = [router matchViewController:@"/q/1000010000?__ea=111"];
XCTAssertEqualObjects(controller.params[@"questionId"], @"1000010000");

Latest podspec

{
    "name": "GMRouter",
    "version": "0.1.1",
    "summary": "A not boring url parser",
    "description": "Not boring about query in url",
    "homepage": "https://github.com/geminiwen/GMRouter",
    "license": "MIT",
    "authors": {
        "Gemini Wen": "[email protected]"
    },
    "source": {
        "git": "https://github.com/geminiwen/GMRouter.git",
        "tag": "0.1.1"
    },
    "social_media_url": "http://weibo.com/coffeesherk",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "GMRouter/*"
}

Pin It on Pinterest

Share This