Skip to content

Instantly share code, notes, and snippets.

@SlappyAUS
Created October 8, 2020 00:09
Show Gist options
  • Save SlappyAUS/5f3149954326a5466ddd92b434f5c66f to your computer and use it in GitHub Desktop.
Save SlappyAUS/5f3149954326a5466ddd92b434f5c66f to your computer and use it in GitHub Desktop.
UserDefaults #data
// 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