Skip to content

Instantly share code, notes, and snippets.

@hramos
Forked from elfredpagan/special_hell
Created December 15, 2011 19:25
Show Gist options
  • Save hramos/1482439 to your computer and use it in GitHub Desktop.
Save hramos/1482439 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
#define dispatch_if_available(queue, code) do{ \
if(dispatch_async != NULL) { \
dispatch_async(queue, ^(void) {\
code\
});\
} else {\
code\
}\
} while(0)
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
dispatch_if_available(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0),
int a = 0;
a++;
NSLog(@"a = %d", a);
);
[p release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment