/AlarmKit

A simple way to create scheduled and repeating alarms in Swift

Primary LanguageShellMIT LicenseMIT

AlarmKit: Simple Alarms in Swift

AlarmKit is a simple way to make clock based alarms in Swift. Great for making clock apps, scheduled notifications, and anything else that depends on code running at an exact time.

Version License Platform

let alarm = AlarmKit.Alarm(weekdays:[.Monday, .Wednesday, .Friday], hour:10, minute:45, {
  doSomethingHereEveryOtherDay()
})

Installation

AlarmKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AlarmKit"

Usage

Creating a one-time alarm

let alarm = AlarmKit.Alarm(hour:10, minute:45, {
  doSomethingOnce()
})

Creating a repeating alarm

let alarm = AlarmKit.Alarm(weekdays:[.Monday, .Wednesday, .Friday], hour:10, minute:45, {
  doSomethingHereEveryOtherDay()
})

Changing the time

let alarm = AlarmKit.Alarm(hour:10, minute:45, {
  doSomethingHere()
})

alarm.hour = 9
alarm.minute = 0

Changing the block

let alarm = AlarmKit.Alarm(hour:10, minute:45, {
  doSomethingHere()
})

alarm.block = {
  doSomethingElseInstead()
}

Turning alarms off/on

let alarm = AlarmKit.Alarm(hour:10, minute:45, {
  doSomethingHere()
})

alarm.turnOff()
alarm.turnOn()

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Daniel Brim, brimizer@gmail.com

License

AlarmKit is available under the MIT license. See the LICENSE file for more info.