SwiftyTimer

码农软件 · 软件分类 · 其他开发相关 · 2019-10-20 13:12:11

软件介绍

SwiftyTimer 是一组扩展,可以使 NSTimer API 更加清晰易用,亲近 Swift 语法。

使用示例:

使用 NSTimer.every 和 NSTimer.after,可轻松地安排重复和不重复计时器(重复和延时):

NSTimer.every(0.7.seconds) {
    statusItem.blink()
}
NSTimer.after(1.minute) {
    println("Are you still here?")
}

SwiftyTimer 使用封闭,而不是目标/选择/用户信息。你可以使用 Ruby on Rails-like 类似的助手,制定时间间隔:

1.second
2.5.seconds
5.seconds
10.minutes
1.hour

  你可以传递方法引用,而不用包:

NSTimer.every(30.seconds, align)

如果你想对一个 Timer 对象不进行计划,使用 use new(after:)new(every:):

let timer = NSTimer.new(every: 1.second) {
    println(self.status)
}

调用 start() 使用  new 来安排计时器的创建,您可以选择通过运行循环和循环运行模式

timer.start()
timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode)


本文地址:https://codercto.com/soft/d/17169.html

Head First Rails

Head First Rails

David Griffiths / O'Reilly Media / 2008-12-30 / USD 49.99

Figure its about time that you hop on the Ruby on Rails bandwagon? You've heard that it'll increase your productivity exponentially, and allow you to created full fledged web applications with minimal......一起来看看 《Head First Rails》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具