码迷,mamicode.com
首页 > 其他好文 > 详细

延时调用

时间:2016-02-18 22:43:50      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

 

  • 方法1:performSelector

    [self performSelector:(SEL) withObject:(id) afterDelay:(NSTimeInterval)]
    

    --SEL 调用哪个方法 --id 参数 --NSTimeInterval 延时时间

  • 方法2:NSTimer

    NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval) target:(id) selector:(SEL) userInfo:(id) repeats:(BOOL)]
    

    -- NSTimeInterval 延迟时间 -- id 调用哪个类 -- SEL 调用哪个方法 -- id  -- BOOL 是否重复

  • 方法3:GCD

    [self performSelector:(SEL) withObject:(id) afterDelay:(NSTimeInterval)]
      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
          延时执行里面的方法 
      });

延时调用

标签:

原文地址:http://www.cnblogs.com/JavaTWW/p/5199344.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!