0707-NSTime

NSTime 定时器

  • 创建NSTime
    // 创建一个定时器
    NSTime timer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(nextPage) userInfo:nil repeats:YES];

    // 将定时器加入主运行循环
    [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

    // 将NSTime赋值给自己的成员变量
    self.time = time;

    // 将定时器停止
    [self.timer invalidate];

    // 将定时器暂停

    // 创建时钟对象
    self.time = [CADisplayLink displayLinkWithTarget:self selector:@selector(step)];

    // 将时钟添加到主运行循环
    [self.time addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];

    // 将定时器停止
    [self.timer invalidate];

    // 将定时器暂停
    self.time.paused = !self.time.paused;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 最近在阅读这本Nicholas C.Zakas(javascript高级程序设计作者)写的最佳实践、性能优化类的书...
    undefinedR阅读 2,167评论 0 30
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,908评论 18 139
  • 1.Runloop基础知识1.1 字面意思 a 运行循环b 跑圈 1.2 基本作用(作用重大) a 保持程序的...
    _Weak阅读 186评论 0 1
  • 第三方框架SDWebImage (1)SDWebImage基本使用01 设置imageView的图片[cell.i...
    _Weak阅读 662评论 0 0
  • 转自:http://blog.csdn.net/jackfrued/article/details/4492194...
    王帅199207阅读 8,602评论 3 93