title: how to cancel a localNotification with the press of a button in swift?
body: <p>I am scheduling a location based <code>UILocalNotification</code> with the click of a button . But when i try to cancel the localNotification by clicking the same button again, it doesn't cancel the notification.
  I am using <code>UIApplication.sharedApplication().cancelLocalNotification(localNotification)</code>
  to cancel my scheduled location based local notification.
  What am i doing wrong ?
  here is my implementation</p>
  
  <pre><code>@IBAction func setNotification(sender: UIButton!) {
      if sender.tag == 999 {
          sender.setImage(UIImage(named: "NotificationFilled")!, forState: .Normal)
          sender.tag = 0
          regionMonitor() //function where notification get scheduled
  
      } else {
          sender.setImage(UIImage(named: "Notification")!, forState: .Normal)
          sender.tag = 999 }
  </code></pre>
  
  <p>what should i enter into the else block so that the scheduled notification gets canceled. Cannot clear all notifications.
  here is the <code>didEnterRegion</code> block code where i trigger the local notification</p>
  
  <pre><code>func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
      localNotification.regionTriggersOnce = true
      localNotification.alertBody = "Stack Overflow is great"
      UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
      NSLog("Entering region")
  }
  </code></pre>