본문 바로가기
# 애플 [Apple]/iOS

[iOS] UserDefaults (How to save user settings using UserDefaults)

by cy_mos 2019. 7. 2.
반응형
How to save user settings using UserDefaults

[iOS] UserDefaults (How to save user settings using UserDefaults)


📄 Swift Source Code

// Save
let defaults = UserDefaults.standard
defaults.set(25, forKey: "Age")
defaults.set(true, forKey: "UseTouchID")
defaults.set(CGFloat.pi, forKey: "Pi")

// Retrive
let age = defaults.integer(forKey: "Age")
let useTouchID = defaults.bool(forKey: "UseTouchID")
let pi = defaults.double(forKey: "Pi")

🚀 REFERENCE

 

How to save user settings using UserDefaults - free Swift 5.0 example code and tips

Was this page useful? Let me know! 1 2 3 4 5

www.hackingwithswift.com

 

UserDefaults - Foundation | Apple Developer Documentation

Posted when ubiquitous defaults finish downloading data, either the first time a device is connected to an iCloud account or when a user switches their primary iCloud account.

developer.apple.com

 

반응형

댓글