A problem has arisen with my program in which it crashes on some specific devices. I've managed to track the problem to a dateFormatter being nil when trying to convert a string to a date. This is only only some devices however.
My question is, how is this possible and is there a problem with how I format my date?
func checkIfActive(start: String, end: String) -> Bool
{
let dateFormatterPrint = DateFormatter()
dateFormatterPrint.dateFormat = "MMMM dd,yyyy hh:mma"
let dateStart = dateFormatterPrint.date(from: start)
let dateEnd = dateFormatterPrint.date(from: end)
print("start time string\(start)") // This print March 19,2018 08:33PM
print("start date\(dateStart)") // This is nil some devices, however works fine on others
if(Date().isBetween(date: dateStart!, andDate: dateEnd!))
{
return true
}
return false
}