Skip to content

Instantly share code, notes, and snippets.

@hramos
Created December 14, 2011 21:55
Show Gist options
  • Save hramos/1478741 to your computer and use it in GitHub Desktop.
Save hramos/1478741 to your computer and use it in GitHub Desktop.
Compile time check for blocks that is of no use when min. target < 4.0 anyway
#ifdef NS_BLOCKS_AVAILABLE
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
#endif
// background stuff
#ifdef NS_BLOCKS_AVAILABLE
dispatch_sync(dispatch_get_main_queue(), ^(void) {
#endif
// main thread stuff
#ifdef NS_BLOCKS_AVAILABLE
});
});
#endif
@hramos
Copy link
Author

hramos commented Dec 14, 2011

Problem: checking against NS_BLOCKS_AVAILABLE at compile time will of course work on a 4.0 or 5.0 SDK app, this is something that needs to be checked at runtime instead - see https://gist.github.com/1478748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment