The problem is when I am inside my formatDate function, if I debug mousing over the dateString variable, I can see the value "3000-01-01T08:00:00-08:00".
But when it reaches the line "let finalDate = dateFormatter.date(from: dateString)!", it returns me the error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value"
The question is how it found nil, if when I mouse over the dateString variable, I can see the value in there ?
func formatDate(dateString: String) -> Date {
//first I dont know why my parameter gets here nil
let dateFormatter = ISO8601DateFormatter()
//at the dateFormatter, doesnt matter the options I set, the return is always the same.
dateFormatter.formatOptions = [
.withFullDate,
.withFullTime,
]
let finalDate = dateFormatter.date(from: dateString)!
return finalDate
}