Created
June 7, 2013 14:09
-
-
Save chris-dannen/5729523 to your computer and use it in GitHub Desktop.
This file contains 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
+ (void)swapMethod:(SEL)origM withMethod:(SEL)newM inClass:(Class)class { | |
Method origMethod = class_getInstanceMethod(class, origM); | |
Method newMethod = class_getInstanceMethod(class, newM); | |
if (class_addMethod(class, origM, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { | |
class_replaceMethod(class, newM, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); | |
} else { | |
method_exchangeImplementations(origMethod, newMethod); | |
} | |
} | |
+ (void)swizzleAPICalls { | |
[HAWStubs swapMethod:@selector(getUserSearchResultsPage:search:delegate:) | |
withMethod:@selector(stubGetUserSearchResultsPage:search:delegate:) | |
inClass:[HAWUserSearchClient class]]; | |
[HAWStubs swapMethod:@selector(getUserProfilePageForID:delegate:) | |
withMethod:@selector(stubGetUserProfilePageForID:delegate:) | |
inClass:[HAWUserProfileClient class]]; | |
// and so on… | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment