Skip to content

Instantly share code, notes, and snippets.

@xmhafiz
Last active April 4, 2021 06:24
Show Gist options
  • Select an option

  • Save xmhafiz/a76145351a9432ca4d573b6c58847a5b to your computer and use it in GitHub Desktop.

Select an option

Save xmhafiz/a76145351a9432ca4d573b6c58847a5b to your computer and use it in GitHub Desktop.
// save name and email
let fullName = "John Smith"
CustomUserDefaults.shared.set(fullName, key: .name)
let userEmail = "john@example.com"
CustomUserDefaults.shared.set(userEmail, key: .email)
// print stored name and email
let savedName = CustomUserDefaults.shared.get(key: .name)
print(savedName) // result: Optional(John Smith)
let savedEmail = CustomUserDefaults.shared.get(key: .email)
print(savedEmail) // result: Optional(john@example.com)
let isUserLogin = CustomUserDefaults.shared.get(key: .isUserLogin)
print(isUserLogin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment