I've started learning Swift and iOS. For learning purpose I've crated a weather app using openweathermap api. In the api response, It gives me the time in Unix UTC time. I've converted the time (Int) to String using this function in extension -
func fromUnixTimeToTimeNDate() -> String {
let date = Date(timeIntervalSince1970: TimeInterval(self))
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM d, h:mm:ss a"
if let retData = dateFormatter.string(for: date) {
return retData
}
return ""
}
So the output in the app looks like -
Now I want to make this uilabel ticking and display the current date and time and updates every seconds. Do I have to use timer() for this? Or there is other solution(s)?