Skip to content

Instantly share code, notes, and snippets.

@craigrbruce
Created August 14, 2013 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save craigrbruce/6227163 to your computer and use it in GitHub Desktop.
Save craigrbruce/6227163 to your computer and use it in GitHub Desktop.
Helper class in obj-c to encapsulate bg tasks
@implementation taskHelper {
}
+ (void)runTaskInBackground:(void (^)())backgroundTask
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), backgroundTask);
}
+ (void)runTaskInForeground:(void (^)())foregroundTask
{
dispatch_async(dispatch_get_main_queue(), foregroundTask);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment