'How can I compare the current time with a specific time?

I have a Label that contains the time in real time. My question is how can I compare the time of the label with 4:00pm. I need to know if the label time is less than or greater than 4:00pm.

My viewDidLoad:


 override func viewDidLoad() {
     labelTiempo.text = DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .short)
     timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector:#selector(self.tick) , userInfo: nil, repeats: true)
     labelFuncion.text = "Funcion: " + filme!.funcion!
    }

//complement function

   @objc func tick() {
     labelTiempo.text = DateFormatter.localizedString(from: Date(), dateStyle: .none,timeStyle: .short)
    }

[screenshot of the view containing the label.][1] [1]: https://i.stack.imgur.com/bIVxG.png



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source