Last Updated: February 25, 2016
·
461
· sghael

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);
}