延迟调用

Posted on 2016-06-29 19:22  柠檬片  阅读(74)  评论(0)    收藏  举报
  • //延迟多少秒后执行block里的方法 

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1(延迟的秒数) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

 

 });

 

  •  //表名2秒钟之后调用自定义的run方法

    [self performSelector:@selector(run) withObject:nil afterDelay:2.0];

 

  • //延迟2秒后,每个2秒调用一次自定义的run方法

    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(run) userInfo:nil repeats:YES];