如何在转换为NSDate后取消从字符串数组中获取的localNotification?

时间:2016-05-23 12:04:01

标签: ios swift localnotification swift2.2

假设这个StringArray有已经在localNotification中安排的Dates字符串,有没有办法获取这些字符串,将它们转换为日期然后删除某个预定日期

var arr = ["2016-08-27 19:29:50 +0000","2016-09-20 17:19:50 +0000","2016-07-27 10:20:30 +0000"]**

func locaNotification(num:Int)

{

    let notification = UILocalNotification()
    let notifTime = NSDate(notificationTime[num])
   UIApplication.sharedApplication().cancelLocalNotification(notification)

}

1 个答案:

答案 0 :(得分:1)

let arrLocalNotif = UIApplication.sharedApplication().scheduledLocalNotifications
for (let localN in arrLocalNotif) {
     let notificationFireDate = localN.fireDate;
    //convert string array value to date object and Compair this bothdate
    if(compair true) {
      UIApplication.sharedApplication().cancelLocalNotification(notification)
            break
    }
}