Last active
December 25, 2015 06:09
-
-
Save numist/6929738 to your computer and use it in GitHub Desktop.
No clang diagnostic pragmas, the only trick is stuffing NSAutoreleasePool into a local to avoid the deprecation-under-ARC warning.
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
// Built for ARC, remove the __bridge and it should work in MRC as well. | |
void *NNCFAutorelease(CFTypeRef cfObject) | |
{ | |
if (cfObject) { | |
static Class arp = Nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
arp = NSClassFromString(@"NSAutoreleasePool"); | |
Assert(arp); | |
}); | |
[arp addObject:(__bridge id)cfObject]; | |
} | |
return (void *)cfObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment