diff options
Diffstat (limited to 'test/ios/LocationMocker/CSSwizzler.m')
-rw-r--r-- | test/ios/LocationMocker/CSSwizzler.m | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/test/ios/LocationMocker/CSSwizzler.m b/test/ios/LocationMocker/CSSwizzler.m deleted file mode 100644 index 70c5b12bc1..0000000000 --- a/test/ios/LocationMocker/CSSwizzler.m +++ /dev/null @@ -1,44 +0,0 @@ -// -// Based on gist by Eric Allam -// https://gist.github.com/ericallam/5689235 -// - -#import "CSSwizzler.h" -#import <objc/message.h> -#import <objc/runtime.h> - -@implementation CSSwizzler - -+ (void)swizzleClass:(id)cls - replaceClassMethod:(SEL)origMethodSelector - withMethod:(SEL)replacementMethodSelector; -{ - Method origMethod = nil, altMethod = nil; - origMethod = class_getClassMethod(cls, origMethodSelector); - altMethod = class_getClassMethod(cls, replacementMethodSelector); - method_exchangeImplementations(origMethod, altMethod); -} - -+ (void)swizzleClass:(id)cls - replaceMethod:(SEL)origMethodSelector - withMethod:(SEL)replacementMethodSelector; -{ - Method origMethod = nil, altMethod = nil; - origMethod = class_getInstanceMethod(cls, origMethodSelector); - altMethod = class_getInstanceMethod(cls, replacementMethodSelector); - method_exchangeImplementations(origMethod, altMethod); -} - -+ (void)swizzleClassOfInstance:(id)inst - replaceMethod:(SEL)origMethodSelector - withMethod:(SEL)replacementMethodSelector; -{ - const char *str = [[[inst class] description] UTF8String]; - Class cls = objc_getClass(str); - Method origMethod = nil, altMethod = nil; - origMethod = class_getInstanceMethod(cls, origMethodSelector); - altMethod = class_getInstanceMethod(cls, replacementMethodSelector); - method_exchangeImplementations(origMethod, altMethod); -} - -@end |