Skip to content

Instantly share code, notes, and snippets.

@bnickel
Created August 26, 2016 17:03
Show Gist options
  • Save bnickel/5288b62a4e4cf69802b04fbeb564a330 to your computer and use it in GitHub Desktop.
Save bnickel/5288b62a4e4cf69802b04fbeb564a330 to your computer and use it in GitHub Desktop.
@import UIKit;
@import JRSwizzle;
@interface UINavigationController (Logging)
@end
@implementation UINavigationController (Logging)
+ (void)load
{
[self jr_swizzleMethod:@selector(setViewControllers:animated:) withMethod:@selector(_SE_setViewControllers:animated:) error:NULL];
[self jr_swizzleMethod:@selector(pushViewController:animated:) withMethod:@selector(_SE_pushViewController:animated:) error:NULL];
[self jr_swizzleMethod:@selector(popViewControllerAnimated:) withMethod:@selector(_SE_popViewControllerAnimated:) error:NULL];
}
- (void)_SE_setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
{
DDLogInfo(@"Setting View Controllers: %@", viewControllers);
[self _SE_setViewControllers:viewControllers animated:animated];
}
- (void)_SE_pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
DDLogInfo(@"Pushing View Controller: %@", viewController);
[self _SE_pushViewController:viewController animated:animated];
}
- (UIViewController *)_SE_popViewControllerAnimated:(BOOL)animated
{
DDLogInfo(@"Popping View Controller: %@", self.visibleViewController);
return [self _SE_popViewControllerAnimated:animated];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment