Skip to content

Instantly share code, notes, and snippets.

@oscahie
Created June 28, 2016 14:21
Show Gist options
  • Save oscahie/5ee213b7f0bd0dbe301affc254450d93 to your computer and use it in GitHub Desktop.
Save oscahie/5ee213b7f0bd0dbe301affc254450d93 to your computer and use it in GitHub Desktop.
track object deallocations on Apple frameworks
#import <objc/runtime.h>
@implementation AVPlayerItem(oscahie)
+ (void)load
{
Method origMethod = class_getInstanceMethod([self class], NSSelectorFromString(@"dealloc"));
Method patchMethod = class_getInstanceMethod([self class], @selector(swizzledDealloc));
method_exchangeImplementations(origMethod, patchMethod);
}
- (void)swizzledDealloc
{
NSLog(@"deallocating object <%@: %p>", [self class], self);
[self swizzledDealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment