{"id":1052,"url":"https://github.com/radex/SwiftyTimer","last_synced_at":"2025-08-06T15:30:32.748Z","repository":{"id":31760880,"uuid":"35327084","full_name":"radex/SwiftyTimer","owner":"radex","description":"Swifty API for NSTimer","archived":false,"fork":false,"pushed_at":"2023-11-29T07:02:09.000Z","size":87,"stargazers_count":1235,"open_issues_count":10,"forks_count":139,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-12-06T22:43:37.680Z","etag":null,"topics":["ios","nstimer","swift","swifty","timer"],"latest_commit_sha":null,"homepage":"http://radex.io/swift/nstimer","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-05-09T12:03:51.000Z","updated_at":"2024-12-05T15:02:15.000Z","dependencies_parsed_at":"2024-01-29T18:06:30.618Z","dependency_job_id":null,"html_url":"https://github.com/radex/SwiftyTimer","commit_stats":{"total_commits":101,"total_committers":11,"mean_commits":9.181818181818182,"dds":"0.39603960396039606","last_synced_commit":"87ef0edd97333264c5fbc2bd3097840f7a7307a1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radex%2FSwiftyTimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radex%2FSwiftyTimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radex%2FSwiftyTimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radex%2FSwiftyTimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radex","download_url":"https://codeload.github.com/radex/SwiftyTimer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228682273,"owners_count":17956491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","nstimer","swift","swifty","timer"],"created_at":"2024-01-05T20:15:37.899Z","updated_at":"2024-12-09T15:30:50.997Z","avatar_url":"https://github.com/radex.png","language":"Swift","readme":"# SwiftyTimer\n\n![Platforms](https://img.shields.io/badge/platforms-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg)\n[![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer)\n[![CocoaPods](http://img.shields.io/cocoapods/v/SwiftyTimer.svg)](https://cocoapods.org/pods/SwiftyTimer)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage)\n![Swift version](https://img.shields.io/badge/swift-4.2-orange.svg)\n\n#### Modern Swifty API for `NSTimer`\n###### SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft.\n\nRead [Swifty APIs: NSTimer](http://radex.io/swift/nstimer/) for more information about this project.\n\n## Usage\n\nYou can easily schedule repeating and non-repeating timers (repeats and delays) using `Timer.every` and `Timer.after`:\n\n```swift\nTimer.every(0.7.seconds) {\n    statusItem.blink()\n}\n\nTimer.after(1.minute) {\n    println(\"Are you still here?\")\n}\n```\n\nYou can specify time intervals with these intuitive helpers:\n\n```swift\n100.ms\n1.second\n2.5.seconds\n5.seconds\n10.minutes\n1.hour\n2.days\n```\n\nYou can pass method references instead of closures:\n\n```swift\nTimer.every(30.seconds, align)\n```\n\n### Manual scheduling\n\nIf you want to make a timer object without scheduling, use `new(after:)` and `new(every:)`:\n\n```swift\nlet timer = Timer.new(every: 1.second) {\n    println(self.status)\n}\n```\n\n(This should be defined as an initializer, but [a bug in Foundation](http://www.openradar.me/18720947) prevents this)\n\nCall `start()` to schedule timers created using `new`. You can optionally pass the run loop and run loop modes:\n\n```swift\ntimer.start()\ntimer.start(modes: .defaultRunLoopMode, .eventTrackingRunLoopMode)\n```\n\n### Invalidation\n\nIf you want to invalidate a repeating timer on some condition, you can take a `Timer` argument in the closure you pass in:\n\n```swift\nTimer.every(5.seconds) { (timer: Timer) in\n    // do something\n    \n    if finished {\n        timer.invalidate()\n    }\n}\n```\n\n## Installation\n\n**Note:** If you're running Swift 2, use [SwiftyTimer v1.4.1](https://github.com/radex/SwiftyTimer/tree/1.4.1)\n\n#### CocoaPods\n\nIf you're using CocoaPods, just add this line to your Podfile:\n\n```ruby\npod 'SwiftyTimer'\n```\n\nInstall by running this command in your terminal:\n\n```sh\npod install\n```\n\nThen import the library in all files where you use it:\n\n```swift\nimport SwiftyTimer\n```\n\n#### Carthage\n\nJust add to your Cartfile:\n\n```ruby\ngithub \"radex/SwiftyTimer\"\n```\n\n#### Manually\n\nSimply copy `Sources/SwiftyTimer.swift` to your Xcode project.\n\n## More like this\n\nIf you like SwiftyTimer, check out [SwiftyUserDefaults](https://github.com/radex/SwiftyUserDefaults), which applies the same swifty approach to `NSUserDefaults`.\n\nYou might also be interested in my blog posts which explain the design process behind those libraries:\n- [Swifty APIs: NSTimer](http://radex.io/swift/nstimer/)\n- [Swifty APIs: NSUserDefaults](http://radex.io/swift/nsuserdefaults/)\n- [Statically-typed NSUserDefaults](http://radex.io/swift/nsuserdefaults/static)\n- [Swifty methods](http://radex.io/swift/methods/)\n\n### Contributing\n\nIf you have comments, complaints or ideas for improvements, feel free to open an issue or a pull request.\n\n### Author and license\n\nRadek Pietruszewski\n\n* [github.com/radex](http://github.com/radex)\n* [twitter.com/radexp](http://twitter.com/radexp)\n* [radex.io](http://radex.io)\n* this.is@radex.io\n\nSwiftyTimer is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["Date \u0026 Time","Libs","Swift","Thread [🔝](#readme)"],"sub_categories":["Getting Started","Thread","Other free courses","Linter","Date"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradex%2FSwiftyTimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradex%2FSwiftyTimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradex%2FSwiftyTimer/lists"}