Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <objc/runtime.h>
- - (void)dealloc
- {
- [CATransaction setCompletionBlock:nil];
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- if ([self respondsToSelector:@selector(setDelegate:)])
- [self performSelector:@selector(setDelegate:) withObject:nil];
- // invalidate timers
- unsigned int count = 0;
- objc_property_t *properties = class_copyPropertyList([self class], &count);
- for (int i = 0; i < count; ++i) {
- NSString *name = [NSString stringWithCString:property_getName(properties[i]) encoding:NSUTF8StringEncoding];
- id prop = [self valueForKey:name];
- if ([prop respondsToSelector:@selector(invalidate)])
- [prop invalidate], prop = nil;
- }
- [super dealloc]; // not needed in ARC
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement