Created
August 15, 2020 16:09
-
-
Save cipolleschi/b22333d947c46d7cef4870197153e956 to your computer and use it in GitHub Desktop.
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
| func extractState() -> Models.User? { | |
| guard | |
| let state = UserDefaults.standard.string(forKey: "state"), | |
| let fileContent = try? String(contentsOfFile: state), | |
| let fileData = fileContent.data(using: .utf8) | |
| else { | |
| return nil | |
| } | |
| return try? JSONDecoder().decode(Models.User.self, from: fileData) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment