Skip to content

Instantly share code, notes, and snippets.

@mavris
Last active July 2, 2017 15:37
Show Gist options
  • Save mavris/22bf9ef8a7410d07e6c6420a371281d9 to your computer and use it in GitHub Desktop.
Save mavris/22bf9ef8a7410d07e6c6420a371281d9 to your computer and use it in GitHub Desktop.
SEL defaultSelector = @selector(setObject:forKey:);
SEL swizzledSelector = @selector(swizzled_setObject:forKey:);
Method defaultMethod = class_getInstanceMethod([self class], defaultSelector);
Method swizzledMethod = class_getInstanceMethod([self class], swizzledSelector);
BOOL isMethodExists = !class_addMethod([self class], defaultSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment