I code therefore I am.

October 24, 2011 at 6:59pm
1 note
Comments (View)
home

Tags:
Objective-C  

Perform a Block after Delay

- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay
{
    int64_t delta = (int64_t)(1.0e9 * delay);
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delta), 
        dispatch_get_main_queue(), block);
}
Then, we use:
[self performBlock: ^{ 
    //Lines of code in block to execute
} afterDelay: 0.5f];

blog comments powered by Disqus

Notes

  1. sourcerer posted this