首页 > 其他 > 详细

延时调用

时间:2016-02-18 22:42:18      阅读:222      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!