Better Navigation in iOS
MIT License
UIViewController+Routing is a handy category, which helps with implementing a better navigation in iOS applications using Routers.
It does the following things at the moment:
###Installation You can install this category in two ways:
Recommended: Install the Cocoapods gem, create Podfile and add the following line:
pod 'UIViewController+Routing', '~> 0.1'
Copy two files, UIViewController+Routing.h and UIViewController+Routing.m to your project.
###Usage
@interface YDRouterBase : NSObject <YDRouter>
@end
Implement any number of navigation methods with the following implementation:
(void)showDetailViewControllerFromSourceViewController:(UIViewController *)sourceViewController withDictionary:(NSDictionary *)detailDictionary { YDSeguePreparationBlock preparationBlock = ^void(UIStoryboardSegue *segue) { YDDetailViewController *destinationViewController = segue.destinationViewController; destinationViewController.detailDictionary = detailDictionary; destinationViewController.router = self; };
[sourceViewController performSegueWithIdentifier:YDDetailSegueIdentifier sender:self preparationBlock:preparationBlock]; }
Implement the - prepareForSegue: method in your router:
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UIViewController *sourceViewController = segue.sourceViewController; YDSeguePreparationBlock block = [sourceViewController preparationBlockForSegue:segue];
if (block) { block(segue); } }
###Example The project now contains a nice demo project, which shows some aspects of using this category and Routers objects. Remember to run pod install before building the demo app. Feel free to ask your questions in the Issues.
###Additional Info Here you can read about using this category for a simple test case (in Russian). And check this [project] for an example of usage this concept in a more realistic app.
UIViewController+Routing is available under the MIT license. See the LICENSE file for more info.