|
[Objective-C] Swizzle Method |
|
 |
// www.prioregroup.com
#import <objc/runtime.h>
void Swizzle(Class c, SEL orig, SEL newClassName)
{
Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, newClassName);
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
class_replaceMethod(c, newClassName, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
else
method_exchangeImplementations(origMethod, newMethod);
}
|
|
|
|
|
|
|
|
Copyright © 1996-2022 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581. |
|
|
|