title: reset date to next hour after top of hour is reached
body: <p>I Want My swift code to count down to the nearest top of the hour. So if the time is 146 the user code should count down 14 minutes. Right now My code below counts down to a spefic day and time. I just want it to count down to the nearest hour when the app is running.</p>
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
      @IBOutlet var timerLabel: UILabel!
      
      var timer: Timer!
      
      override func viewDidLoad() {
          super.viewDidLoad()
          timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(UpdateTime), userInfo: nil, repeats: true)
      }
      
      @objc func UpdateTime() {
          let userCalendar = Calendar.current
          // Set Current Date
          let date = Date()
          let components = userCalendar.dateComponents([.hour, .minute, .month, .year, .day], from: date)
          let currentDate = userCalendar.date(from: components)!
          
          // Set Event Date
          var eventDateComponents = DateComponents()
          eventDateComponents.year = 2021
          eventDateComponents.month = 01
          eventDateComponents.day = 01
          eventDateComponents.hour = 01
          eventDateComponents.minute = 00
  
          eventDateComponents.timeZone = TimeZone(abbreviation: &quot;GMT&quot;)
          
  
          let eventDate = userCalendar.date(from: eventDateComponents)!
          
          let timeLeft = userCalendar.dateComponents([.day, .hour, .minute, ], from: currentDate, to: eventDate)
      
          timerLabel.text = &quot;\(timeLeft.day!)d \(timeLeft.hour!)h \(timeLeft.minute!)m &quot;
  
          endEvent(currentdate: currentDate, eventdate: eventDate)
      }
      
      func endEvent(currentdate: Date, eventdate: Date) {
          if currentdate &gt;= eventdate {
              timerLabel.text = &quot;Happy New Year!&quot;
              // Stop Timer
              timer.invalidate()
          }
      }
  }
  </code></pre>
  <p>edit/update:</p>
  <p>My goal in my swift code is when the top of the hour is reached. After trying to implement @Leo's answer it prints &quot;Top of Hour&quot; and it does the problem is that It only does it one time. As long as the app is open I want it to print &quot;Top of Hour&quot; at every hour. So I need to reset the end date which is what I tried to do at</p>
  <blockquote>
  <p>let date = Date()
  end = date.nextHour</p>
  </blockquote>
  <p>That does not let the code compile. So I have to reset the end var to the next hour.</p>