I am working on a application where i need to convert a date from string to Date format according to Swift. I have write a code for converting String date to Date format and that was working fine when i was checking it on simulator on iPhone 7, 6, 6plus and etc. And also working great when i was checking it on iPhone 5s, and 4s. But when i try to check my application with iPhone 7 Real device then my application getting crashed on a error.
And The error is :- fatal error: unexpectedly found nil while unwrapping an Optional value
As i debug my application in iPhone 7 then i am getting problem to convert a string date into Date format.
this the code which is i am using to convert a String date into Date in Swift
print("wakeupDateTime=\(wakeupDateTime)")
let dtf = DateFormatter()
dtf.timeZone = TimeZone.autoupdatingCurrent
dtf.dateFormat = "yyyy-MM-dd HH:mm:ss"
let defaultStartdate = dtf.date(from: wakeupDateTime)!
print(defaultStartdate)
Here my wakeupDateTime
is 2016-12-12 11:13:44
Please help me for that. thanks