Error if iOS device preferred device language other than English
Error if iOS device preferred device language other than English.
Easy t test, just switch language from device Settings > General > Language & Region > Make any other language first on Preferred Language order.
Date picker will report error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value!" in CalendarHelper.swift "return date!" line 89
Changing BDate.swift getMonths() class to the following fixes the issue
class func getMonths() -> [String]{ //return ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"] let formatter = DateFormatter() let monthComponents = formatter.shortMonthSymbols return monthComponents! }
As it uses localised month short strings to visualise month in picker and uses same values to parse date from string in CalendarHelper.swift (let date = dateFormatter.date(from: "(currentMonth)/(currentDay)/(currentYear)"))
At least it works for me in Basque and Spanish
In addition to the fix, now the months are shown in the language used by the user in the device (and not only in English like before)
Hello @mkelitz The following fix will do the trick. Change the array to ["01", "02", "03"...."12"]. The date will still be recognizable & usable.