TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2016 |
Maintained by Elethom Hunter.
URL router framework for iOS
Here's a typical way of navigating through view controllers:
#import "MyViewController.h"
...
MyViewController *controller = [[MyViewController alloc] init];
controller.someProperty = someProperty;
controller.someOtherProperty = someOtherProperty
[self.navigationController pushViewController:controller
animated:YES];
Here's the same job did with a router.
[[PRRouter defaultRouter] openURL:myModel.url
withNavigationController:self.navigationController];
Benefits of using a router:
@implementation PRUserViewController
...
#pragma mark - Life cycle
+ (void)load
{
[[PRRouter defaultRouter] mapPath:@"/user/:user_id"
toControllerClass:self];
}
...
@end
-initWithParams:query:fragment:
@implementation PRUserViewController
...
- (instancetype)initWithParams:(NSDictionary *)params
query:(NSDictionary *)query
fragment:(NSString *)fragment
{
self = [super initWithParams:params
query:query
fragment:fragment];
if (self) {
// Initialize your view controller
}
return self;
}
...
@end
@implementation PRContactsViewController
...
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PRContact *contact = self.viewModel.objects[indexPath.row];
[[PRRouter defaultRouter] openURL:contact.url
withNavigationController:self.navigationController];
}
...
@end
See Documentation.
This project is released under the terms and conditions of the MIT license. See LICENSE for details.
This project is designed and developed by Elethom Hunter. You can reach me via:
You can support me by:
:-)