Swift查找上次计划的本地通知

时间:2016-12-12 02:56:32

标签: ios swift uilocalnotification

执行64本地通知限制我正在尝试查找距离当前日期最远的通知。目前我的代码是:

if let scheduledLocalNotifications = UIApplication.sharedApplication().scheduledLocalNotifications {
    if let farthestLocalNotification = scheduledLocalNotifications.maxElement({ (notification1, notification2) -> Bool in
        guard let fireDateNotification1 = notification1.fireDate, fireDateNotification2 = notification2.fireDate else { return false }
        return fireDateNotification1.isBefore(fireDateNotification2)
    }) {
            return farthestLocalNotification
       }
    }
    return nil
}

这样可以正常工作,但在分析它时,速度相当慢。有没有更有效的方法来做到这一点?

0 个答案:

没有答案