mirror of
https://github.com/samsonjs/NotificationTask.git
synced 2026-03-25 09:15:55 +00:00
22 lines
526 B
Swift
22 lines
526 B
Swift
import Foundation
|
|
@testable import NotificationTask
|
|
|
|
@MainActor class SimplestVersion {
|
|
let task = NotificationTask(name: .NSCalendarDayChanged) { _ in
|
|
print("The date is now \(Date.now)")
|
|
}
|
|
}
|
|
|
|
@MainActor class WithContext {
|
|
var notificationTask: NotificationTask?
|
|
|
|
init() {
|
|
notificationTask = NotificationTask(name: .NSCalendarDayChanged, context: self) { _self, _ in
|
|
_self.dayChanged()
|
|
}
|
|
}
|
|
|
|
func dayChanged() {
|
|
print("The date is now \(Date.now)")
|
|
}
|
|
}
|