2014年2月28日星期五

how to call a method with delay

http://stackoverflow.com/questions/9634790/how-to-call-a-method-with-delay

use dispatch_after:
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    //code to be executed on the main queue after delay
    [self MoveSomethingFrom:from To:to];
});

没有评论:

发表评论