I have a UILabel which displays my current 24 hour countdown. I would like to check if the countdown is at zero and when it is to update my UILabel. The way it is set up now if it is reached 24 hours it keeps running as negative numbers. For example -1h-55m-54s

I have tried to check if UILabel contains "-" and also if the value is less than 0 however have not got it to work.

```
        func timeLeftExtended(date:Date) ->NSAttributedString{

    let cal = Calendar.current
    let now = Date()
    let calendarUnits:NSCalendar.Unit = [NSCalendar.Unit.hour, NSCalendar.Unit.minute, NSCalendar.Unit.second]
    let components = (cal as NSCalendar).components(calendarUnits, from: now, to: date, options: [])

    let fullCountDownStr = "\(components.hour!.description)h " + "\(components.minute!.description)m " + "\(components.second!.description)s "
    let mutableStr = NSMutableAttributedString(string: fullCountDownStr, attributes: [NSAttributedString.Key.foregroundColor:UIColor.white])

    for (index, char) in mutableStr.string.enumerated()
    {
        if(char == "h" || char == "m" || char == "s")
        {
            mutableStr.removeAttribute(NSAttributedString.Key.foregroundColor, range: NSMakeRange(index, 1))
            mutableStr.addAttributes([NSAttributedString.Key.foregroundColor : UIColor.lightGray], range: NSMakeRange(index, 1))
        }
    }

    return mutableStr
}

        func updateCountDown() {
    if let waitingDate = UserDefaults.standard.value(forKey: "waitingDate") as? Date {

     if let waitingDate = UserDefaults.standard.object(forKey: "waitingDate") as? Date,
        waitingDate < Date() {

        self.timeLabel.text = "Time ran out"
        print("It is time for you to check in")
    }
      //  if self.timeLeftExtended(date: waitingDate) <= 0{
      //change label
}

        self.timeLabel.attributedText = self.timeLeftExtended(date: waitingDate)

    } else {
        let newDate = Calendar.current.date(byAdding: .hour, value: 24, to: Date())
        UserDefaults.standard.set(newDate, forKey: "waitingDate")
        self.timeLabel.attributedText = self.timeLeftExtended(date: newDate!)

    }
}

```