Skip to content

Instantly share code, notes, and snippets.

@typester
Created November 30, 2009 15:30
Show Gist options
  • Save typester/245494 to your computer and use it in GitHub Desktop.
Save typester/245494 to your computer and use it in GitHub Desktop.
#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