Created
August 20, 2015 11:57
-
-
Save metasmile/cf88df9207d3ba9e8830 to your computer and use it in GitHub Desktop.
dealloc in category
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
#define BEGIN_DEALLOC_CATEGORY + (void)load {\ | |
SEL originalSelector = NSSelectorFromString(@"dealloc");\ | |
SEL overrideSelector = @selector(__dealloc__);\ | |
Method originalMethod = class_getInstanceMethod(self, originalSelector);\ | |
Method overrideMethod = class_getInstanceMethod(self, overrideSelector);\ | |
if (class_addMethod(self, originalSelector, method_getImplementation(overrideMethod), method_getTypeEncoding(overrideMethod))) {\ | |
class_replaceMethod(self, overrideSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));\ | |
} else {\ | |
method_exchangeImplementations(originalMethod, overrideMethod);\ | |
}\ | |
}\ | |
\ | |
- (void)__dealloc__{\ | |
#define END_DEALLOC_CATEGORY } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment