https://github.com/nicolaskim/dtrouter
Simple Router
https://github.com/nicolaskim/dtrouter
ios objective-c ripper route router
Last synced: about 1 year ago
JSON representation
Simple Router
- Host: GitHub
- URL: https://github.com/nicolaskim/dtrouter
- Owner: NicolasKim
- License: mit
- Created: 2017-03-08T14:23:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T12:57:03.000Z (about 9 years ago)
- Last Synced: 2025-03-23T03:51:15.621Z (about 1 year ago)
- Topics: ios, objective-c, ripper, route, router
- Language: Objective-C
- Homepage: http://www.jianshu.com/p/e6d20e409712
- Size: 271 KB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DTRouter
[](https://travis-ci.org/jinqiucheng1006@live.cn/DTRouter)
[](http://cocoapods.org/pods/DTRouter)
[](http://cocoapods.org/pods/DTRouter)
[](http://cocoapods.org/pods/DTRouter)
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
DTRouter is available through [CocoaPods]([http://cocoapods.org](http://cocoapods.org)). To install
it, simply add the following line to your Podfile:
```ruby
pod "DTRouter"
or 'DTRouter/Core'
or 'DTRouter/UI'
```
## Usage
```objective-c
//regist
-(void)addRouter:(NSString *)URLPattern handler:(DTRouterRegistHandler)handler;
//route
-(DTRouterResponse *)route:(NSString *)URLString arguments:(NSDictionary *)arguments;
-(NSOperation *)asyncRoute:(NSString *)URLString arguments:(NSDictionary *)arguments handler:(DTResponseBlock)handler;
```
```objective-c
//regist
[[DTRouterService sharedInstance]addRouter:@"addnumber/:num" handler:^id(NSDictionary *paths, NSDictionary *arguments) {
NSString * num = paths[@"num"];
handler handle = arguments[@"taskkey"];
return nil;
}];
//route
handler h = ^(long long num){
NSLog(@"current num : %lld",num);
};
[[DTRouterService sharedInstance]asyncRoute:@"addnumber/100" arguments:@{@"taskkey":h} handler:^(DTRouterResponse *response) {
NSLog(@"result : %@",response.resultValue);
}];
```
## Author
jinqiucheng1006@live.cn
## License
DTRouter is available under the MIT license. See the LICENSE file for more info.