欢迎加入QQ讨论群258996829

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

发布时间:2017-07-20 22:14  回复:0  查看:6769  感兴趣:103  赞:5   最后回复:2017-07-20 22:14  
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()


相关开源代码

您还未登录,请先登录

热门帖子

最新帖子