Created
November 30, 2009 15:30
-
-
Save typester/245494 to your computer and use it in GitHub Desktop.
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 "Meta.h" | |
| #import <objc/runtime.h> | |
| @implementation Meta | |
| @synthesize info; | |
| +(id)instance { | |
| static id _instance = nil; | |
| @synchronized(self) { | |
| if (!_instance) { | |
| _instance = [[self alloc] init]; | |
| [_instance inject]; | |
| } | |
| } | |
| return _instance; | |
| } | |
| typedef void (* func_imp)(NSObject *obj, SEL cmd, NSObject *camera, UIImage *image, UIImage *preview, NSData *jpg, NSDictionary *props); | |
| static func_imp func_original; | |
| static void func(NSObject *obj, SEL cmd, NSObject *camera, UIImage *image, UIImage *preview, NSData *jpg, NSDictionary *props) { | |
| Meta *meta = [Meta instance]; | |
| meta.info = props; | |
| return func_original(obj, cmd, camera, image, preview, jpg, props); | |
| } | |
| -(void)inject { | |
| Class class = objc_getClass("PLCameraView"); | |
| if (NULL != class) { | |
| Method method = class_getInstanceMethod(class, @selector(cameraController:tookPicture:withPreview:jpegData:imageProperties:)); | |
| if (method) { | |
| func_original = (func_imp)method_setImplementation(method, (IMP)func); | |
| NSLog(@"installed metaclass"); | |
| } | |
| } | |
| } | |
| -(void)dealloc { | |
| [info release]; | |
| [super dealloc]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment