Execute a task in background

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    //Your code here...
});

Execute a task on the main thread

dispatch_async(dispatch_get_main_queue(), ^{
    //Your code here...
});

Execute a task after delay

// Delay execution of my block for 10 seconds.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    //Your code here...
});

results matching ""

    No results matching ""