Created
July 7, 2011 16:53
-
-
Save AlanQuatermain/1069966 to your computer and use it in GitHub Desktop.
I love the ObjC runtime sometimes…
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
+ (void) load | |
{ | |
if ( dispatch_barrier_async == 0 ) | |
return; | |
// switch in the dispatch_barrier_async() versions since they're available | |
Method m1 = class_getInstanceMethod(self, @selector(handleEventsForObserver:usingBlock:)); | |
Method m2 = class_getInstanceMethod(self, @selector(_barrier_handleEventsForObserver:usingBlock:)); | |
if ( m1 != NULL && m2 != NULL ) | |
method_exchangeImplementations(m1, m2); | |
m1 = class_getInstanceMethod(self, @selector(handleCancelEventsForObserver:usingBlock:)); | |
m2 = class_getInstanceMethod(self, @selector(_barrier_handleCancelEventsForObserver:usingBlock:)); | |
if ( m1 != NULL && m2 != NULL ) | |
method_exchangeImplementations(m1, m2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment