Swift51.com
Swift 头像
Swift  2017-07-20 22:14

Swift 优雅的定时器及执行工具库 Each

回复:0  查看:6768  感兴趣:103  赞:5  
Each 是一个优雅的定时器及执行工具库,用Swift编写。
特性:
  • 完全可配置的定时器   
  • 支持以毫秒,秒,分和小时为单位的时间间隔   
  • 完全可扩展   
  • 与NSTimer对象相比,使用起来更加可读和简单
示例代码:
let timer = Each(1).seconds     // Can be .milliseconds, .seconds, .minute, .hours  

timer.perform {
    // Do your operations
    // This closure has to return a NextStep value
    // Return .continue if you want to leave the timer active, otherwise
    // return .stop to invalidate it
}

timer.stop()    // This stops immediately the timer

timer.restart()


相关开源代码