Skip to content

SHEEP-King/GCDTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EZKit

v0.0.1 增加EZTimer控件,封装GCD版timer。

v0.0.2 增加timer状态控制,内部控制suspend等的配对使用,用户使用不再需要注意配对使用的问 题,使用更加方便简单。

用法简单: 创建timer 并执行 /**

  • 简单方式创建并执行timer,其他未给出的参数均为默认参数
  • timerName timer的名称,创建好的timer以name为key存储于timers字典中
  • interval timer时间间隔
  • resumeType 是否立刻开始执行,默认立刻开始执行,此时block会立刻执行,next下一个interval执行
  • action timer回调 / -(void)repeatTimer:(NSString)timerName timerInterval:(double)interval resumeType:(EZTimerResumeType)resumeType action:(EZTimerBlock)action;

[[EZTimer shareInstance] timer:@"logNumber" timerInterval:5 leeway:0.1 resumeType:EZTimerQueueTypeNext queue:EZTimerQueueTypeConcurrent queueName:@"log" repeats:YES action:^(NSString *timerName) { static NSInteger number = 1; dispatch_sync(dispatch_get_main_queue(), ^{ self.numLabel.text = @(number).stringValue; number ++; }); }];

/**

  • 注销此timer
  • timerName timer名称 / -(void)cancel:(NSString )timerName; /
  • 暂停此timer
  • 暂停及恢复的操作不建议使用,这两个操作需配对使用,
  • 不然会出现崩溃,原因是source未提供检测状态的接口
  • timerName timer名称 / -(void)pause:(NSString )timerName; /
  • 恢复此timer
  • 暂停及恢复的操作不建议使用,这两个操作需配对使用,
  • 不然会出现崩溃,原因是source未提供检测状态的接口
  • timerName timer名称 */ -(void)resume:(NSString *)timerName;

About

gcd版timer,命名为EZTimer。解决NSTimer中的runloop,线程及内存管理问题,操作简单,使用方便。EZTimer可以同时创建多个timer互不影响,通过timer名字区分,同时暂停恢复及撤销不用担心配对使用问题,完全解放您的双手。

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors