Created
April 28, 2014 22:46
-
-
Save matinm/11386280 to your computer and use it in GitHub Desktop.
Automatic event-tracking for iOS analytics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "UIApplication+EventAutomator.h" | |
| #import <objc/runtime.h> | |
| @implementation UIApplication (EventAutomator) | |
| + (void)load { | |
| Class class = [self class]; | |
| SEL originalSelector = @selector(sendAction:to:from:forEvent:); | |
| SEL replacementSelector = @selector(heap_sendAction:to:from:forEvent:); | |
| Method originalMethod = class_getInstanceMethod(class, originalSelector); | |
| Method replacementMethod = class_getInstanceMethod(class, replacementSelector); | |
| method_exchangeImplementations(originalMethod, replacementMethod); | |
| } | |
| - (BOOL)heap_sendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event { | |
| NSString *selectorName = NSStringFromSelector(action); | |
| printf("Selector %s occurred.\n", [selectorName UTF8String]); | |
| return [self heap_sendAction:action to:target from:sender forEvent:event]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment