GCDMacros - iOS
Header:
//
// GCDMacros.h
//
#ifndef GCDMacros_h
#define GCDMacros_h
typedef void(^VoidBlock)();
void UIThread(VoidBlock block);
void BackgroundThread(VoidBlock block);
#endif
Implementation:
//
// GCDMacros.m
//
#import "GCDMacros.h"
void UIThread(VoidBlock block)
{
dispatch_async(dispatch_get_main_queue(), block);
}
void BackgroundThread(VoidBlock block)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}
Written by Sandeep Ghael
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Gcd
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#