Skip to content

Commit

Permalink
Update README/Usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
lightory committed Mar 18, 2014
1 parent 9d4317f commit aa6a86c
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
HHRouter
=====
Yet another URL Router for iOS. Clean, Fast & Powerful.
Yet another URL Router for iOS. Clean, Fast & Flexable. Inspired by [ABRouter](https://github.com/aaronbrethorst/ABRouter) & [Routable for iOS](https://github.com/usepropeller/routable-ios).

## Usage

### Warm Up

Map URL patterns to viewController. Better in AppDelegate.

```objective-c
[[HHRouter shared] map:@"/user/:userId/" toControllerClass:[UserViewController class]];
```
Define a `NSDictionary` property named `params` in viewControllers. Better in your BaseViewController.
```objective-c
@interface UserViewController : UIViewController
@property (strong, nonatomic) NSDictionary *params;
@end
```

### Exciting Time
Get viewController Instance from URL. Params will be automatic parsed.

```objective-c
UIViewController *viewController = [HHRouter shared] match:@"/user/1/"];
```

`viewController` will be an instance of UserViewController. And `viewController.params` will be `@{ @"route": @"/user/1/", @"userId": @"1"}`.

### URL Query Params

URL Query Params is also supported. This will make things VERY flexable.

```objective-c
UIViewController *viewController = [HHRouter shared] match:@"/user/1/?tabIndex=3"];
```

`viewController.params[@"tabIndex"]` would be `3`.

### One More Thing

If your app has defined some url schemes, HHRouter will know.

In the HHRouterExample Project, `hhrouter://user/1/` and `/user/1/` map to the same UIViewController.

## Installation
### [CocoaPods](http://cocoapods.org/)
Expand Down

0 comments on commit aa6a86c

Please sign in to comment.