-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
NSDate fetch crash on some dates #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am running into this same problem. |
it can be possible, but somebody else have to redesign whole Value methods for it. You could use custom DateFormatter to pass timeIntervalSince1970 |
I had the same issue and the fix, for me at least, was a bit subtle. So I noticed the crash would happen despite stringValue being an acceptable date string. This didn't make sense. Why would it crash when given a perfectly acceptable date value? Turns out this insight was a big clue: What was actually happening was dateFormatter was causing the problem. Specifically, dateFormatter was being given a different format than the passed in string a bit later in my code, as in:
This new format would then be applied to the one in SQLite > Foundation.swift, which would, when I had a date with a different format get selected, cause the crash. In other words I'd give it a string just like yours, but the formatter expected a string in my new format. The date conversion would fail and the optional unwrap would cause a crash. The fix then, again, for me at least, was to simply set the proper format before the database column was accessed. For example:
..Access database column..
etc... Alternatively, we can search for an remove any calls to dateFormatter.dateFormat in our project. |
Possible it is better to use optional there ...

The text was updated successfully, but these errors were encountered: