【发布时间】:2019-11-13 02:53:57
【问题描述】:
我正在实施自定义重复提醒,例如默认提醒应用。在这里,我不介绍如何设置重复间隔,例如每隔 N 天/周/月/年触发一次,即从现在开始每隔 4 天/周/月/年触发一次通知。
这是我对区间 = 1 的实现
if type == .daily{
dateComponents = Calendar.current.dateComponents([.hour, .minute], from: Date())
}else if type == .weekly{
dateComponents = Calendar.current.dateComponents([.hour, .minute,.weekday], from: Date())
}else if type == .monthly{
dateComponents = Calendar.current.dateComponents([.day,.hour, .minute], from: Date())
}else if type == .yearly{
dateComponents = Calendar.current.dateComponents([.hour, .minute,.day,.month], from: Date())
}
【问题讨论】:
标签: ios swift local nsnotificationcenter unusernotificationcenter