Last active
October 11, 2016 22:13
-
-
Save keith/a121589b4f376b46da868c70f7460ab3 to your computer and use it in GitHub Desktop.
Implicitly unwrapped optional crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func set<T>(value: T, forKey key: String) { | |
UserDefaults.standard.set(value, forKey: key) // this crashes because it's trying to store Optional<Date> | |
} | |
let date: Date! = Date() | |
set(value: date, forKey: "key") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment