SwiftyTimer alternatives and similar libraries
Based on the "Date & Time" category.
Alternatively, view SwiftyTimer alternatives based on common mentions on social networks and blogs.
-
SwiftDate
🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift. -
NSDate-TimeAgo
DISCONTINUED. A "time ago", "time since", "relative date", or "fuzzy date" category for NSDate and iOS, Objective-C, Cocoa Touch, iPhone, iPad. -
TrueTime
NTP library for Swift and Objective-C. Get the true time impervious to device clock changes. -
iso-8601-date-formatter
A Cocoa NSFormatter subclass to convert dates to and from ISO-8601-formatted strings. Supports calendar, week, and ordinal formats. -
10Clock
This Control is a beautiful time-of-day picker heavily inspired by the iOS 10 "Bedtime" timer. -
TimeZonePicker
A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftyTimer or a related project?
README
SwiftyTimer
Modern Swifty API for NSTimer
Read Swifty APIs: NSTimer for more information about this project.
Usage
You can easily schedule repeating and non-repeating timers (repeats and delays) using Timer.every
and Timer.after
:
Timer.every(0.7.seconds) {
statusItem.blink()
}
Timer.after(1.minute) {
println("Are you still here?")
}
You can specify time intervals with these intuitive helpers:
100.ms
1.second
2.5.seconds
5.seconds
10.minutes
1.hour
2.days
You can pass method references instead of closures:
Timer.every(30.seconds, align)
Manual scheduling
If you want to make a timer object without scheduling, use new(after:)
and new(every:)
:
let timer = Timer.new(every: 1.second) {
println(self.status)
}
(This should be defined as an initializer, but a bug in Foundation prevents this)
Call start()
to schedule timers created using new
. You can optionally pass the run loop and run loop modes:
timer.start()
timer.start(modes: .defaultRunLoopMode, .eventTrackingRunLoopMode)
Invalidation
If you want to invalidate a repeating timer on some condition, you can take a Timer
argument in the closure you pass in:
Timer.every(5.seconds) { (timer: Timer) in
// do something
if finished {
timer.invalidate()
}
}
Installation
Note: If you're running Swift 2, use SwiftyTimer v1.4.1
CocoaPods
If you're using CocoaPods, just add this line to your Podfile:
pod 'SwiftyTimer'
Install by running this command in your terminal:
pod install
Then import the library in all files where you use it:
import SwiftyTimer
Carthage
Just add to your Cartfile:
github "radex/SwiftyTimer"
Manually
Simply copy Sources/SwiftyTimer.swift
to your Xcode project.
More like this
If you like SwiftyTimer, check out SwiftyUserDefaults, which applies the same swifty approach to NSUserDefaults
.
You might also be interested in my blog posts which explain the design process behind those libraries:
Contributing
If you have comments, complaints or ideas for improvements, feel free to open an issue or a pull request.
Author and license
Radek Pietruszewski
SwiftyTimer is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the SwiftyTimer README section above
are relevant to that project's source code only.