Skip to content

Instantly share code, notes, and snippets.

@diwu
diwu / NavInjection.m
Last active December 31, 2015 07:46
A Quick Way Of Knowing Which View Controller You Are Pushing Into
//A Quick Way Of Knowing Which View Controller You Are Pushing Into
//I find it extremely useful when debugging other team members' (unfamiliar) code
//Usage: Drop the snippet into a blank .m file. It'll NSLog when you are pushing a view controller.
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <objc/message.h>
typedef void(^Block_IMP_pushViewController_animated)(__unsafe_unretained id _self, __unsafe_unretained id arg1, BOOL arg2);
static BOOL replaceMethodWithBlock(Class c, SEL origSEL, SEL newSEL, id block) {