????Object-C????????з????????????з??????????????????
??????NSString?????????????lowercaseString??uppercaseString??????????????????????:
????Method originalMethod = class_getInstanceMethod([NSString class]?? @selector(lowercaseString));
????Method swappedMethod = class_getInstanceMethod([NSString class]?? @selector(uppercaseString));
????????????:
????method_exchangeImplementations(originalMethod?? swappedMethod);
???????????????????NSString????????lowercaseString???????е????uppercaseString??????????????
???????????б?????????????????????????????????“???????????”???????????????????????Щ???????????????????????????????????IMP???????????:
????id (*IMP) (id?? SEL?? ...)
??????????????????????IMP???
?????????????????????У??????????????????岢???????????????????????????????
??????????????????д???????:
@implementation NSString (MyAdditions)
- (NSString *)myLowercaseString
{
NSString *lowercase = [self myLowercaseString];
NSLog(@"%@ => %@"?? self?? lowercase);
return lowercase;
}
@end
???????????????????????????????????????lowercaseString??????????:
????Method originalMethod = class_getInstanceMethod([NSString class]?? @selector(lowercaseString));
????Method swappedMethod = class_getInstanceMethod([NSString class]?? @selector(myLowercaseString));
????method_exchangeImplementations(originalMethod?? swappedMethod);
??????????????????????????Щ“????????????????”???з????????????????????????????????????????????????????????????????????????????????????????????????????ò?????????????