Created
October 8, 2020 00:09
-
-
Save SlappyAUS/5f3149954326a5466ddd92b434f5c66f to your computer and use it in GitHub Desktop.
UserDefaults #data
This file contains 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
// Controller | |
let defaults = UserDefaults.standard | |
// Reading | |
if let items = defaults.array(forKey: "TodoListArray") as? [String] { | |
itemArray = items | |
} | |
else { | |
itemArray = [] | |
} | |
// Writing | |
self.defaults.setValue(self.itemArray, forKey: "TodoListArray") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment