【发布时间】:2016-06-19 13:15:56
【问题描述】:
有没有一种快速有效的方法来查找预定通知? Find list of Local Notification the app has already set 讨论遍历列表,这就是我所做的:
// To avoid duplicate notifications, check whether there are already scehduled notifications with the same fireDate, reminderName and calendar name.
if let definiteDueDateComponents = reminder.dueDateComponents, definiteDueDate = definiteDueDateComponents.date, definiteScheduledNotifications = UIApplication.sharedApplication().scheduledLocalNotifications {
for notification in definiteScheduledNotifications {
if notification.fireDate?.compare(definiteDueDate) == .OrderedSame {
// Check whether there is already a notification set up for definiteDueDate?
// If so, check whether the notification is actually for the same item that I want to set up here.
}
}
}
但是,这可能会变得低效,特别是如果我有很多项目要在安排它们之前检查(运行上面的代码),而且如果我已经有各种安排的通知。
有没有人尝试过创建预定通知的字典(哈希表)?如果是这样,您何时创建并重新创建它?尝试使哈希表与UIApplication.sharedApplication().scheduledLocalNotifications 保持同步是否很麻烦?
【问题讨论】:
标签: ios swift uilocalnotification