title: Get minutes remaining between dates in Swift
body: <p>My question is based on a time interval</p>
  
  <p>I'm getting the hour and minutes (NOW) and I want to create a timer for 75 minutes since that moment but I want the timer to continue working even if i close the app even on multitasking</p>
  
  <p>So i was thinking if I save the time as a NSUserDefault value and every time I open the app It reads the stored value and recalculates</p>
  
  <p>This is my actual code</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
  
      var timer = NSTimer.scheduledTimerWithTimeInterval(30, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
  }
  
  func update() {
      //here I should update the GUI with the remaining minutes and do a NSUserDefault check if the 75 minutes have already
  }
  
  @IBAction func save_time(sender: AnyObject) {
  
      let date = NSDate()
      let calendar = NSCalendar.currentCalendar()
      let components = calendar.components(.CalendarUnitHour | .CalendarUnitMinute, fromDate: date)
      var hour = components.hour
      var minutes = components.minute + 75
      if (minutes&gt;59){
          hour += 1
          minutes -= 60
      }
      defs.setInteger(hour, forKey: "u_hora")
      defs.setInteger(minutes, forKey: "u_minutos")
  
  
  }
  </code></pre>