-1

Let’s say this StringArray has strings of Dates which are already scheduled in localNotification, is there a way to get those strings, convert them to dates and then remove a certain scheduled date

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)

}
Larme
  • 24,190
  • 6
  • 51
  • 81
  • Look for `NSDateFormatter` to transform `NSDate` into `NSString` or `NSString` into `NSDate`. – Larme May 23 '16 at 12:19

1 Answers1

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
    }
}
Shreyank
  • 1,549
  • 13
  • 24
  • could you write it please with Swift ? – Ahmad Khawatmi May 23 '16 at 12:58
  • just wrote it in Swift and it worked =) thanks a lot – Ahmad Khawatmi May 23 '16 at 13:48
  • though i have one last issue ! when i compare both dates in the if statement i get in the output : 2016-05-23 13:55:00 +0000 2016-05-23 13:53:38 +0000 which means the condition will never be true because there is always difference in seconds ! do you know any method to ignore comparing seconds ? – Ahmad Khawatmi May 23 '16 at 13:52