Skip to content

Instantly share code, notes, and snippets.

@KiranPanesar
Last active August 29, 2015 14:19
Show Gist options
  • Save KiranPanesar/aa96b63a93f7811597a0 to your computer and use it in GitHub Desktop.
Save KiranPanesar/aa96b63a93f7811597a0 to your computer and use it in GitHub Desktop.
/*
We're directly including this file into Tweak.xmi at build time.
Tweak.xmi includes/defines the following things:
*/
#import "../CallTracer.h"
#import "../SQLiteStorage.h"
#import "../PlistObjectConverter.h"
%hook NSString
+ (id)stringWithFormat:(NSString *)format {
NSString *origResult = %orig(format);
SQLiteStorage *traceStorage = [SQLiteStorage new];
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"NSString" andMethod:@"stringWithFormat:"];
[tracer addArgFromPlistObject:format withKey:@"string"];
[tracer addReturnValueFromPlistObject:[PlistObjectConverter convertNSString: origResult]];
[traceStorage saveTracedCall: tracer];
[tracer release];
return origResult;
}
%end
/* vim: set filetype=objc : */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment