반응형
An interface to the user’s defaults database, where you store key-value pairs persistently across launches of your app.
- integer (forKey:)
- bool (forKey:)
- float (forKey:)
- double (forKey:)
- object (forKey:)
📄 UserDefaultes Swift Source Code
let defaults = UserDefaults.standard
// SAVE
defaults.set(25, forKey: "Age")
defaults.set(true, forKey: "UseTouchID")
defaults.set(CGFloat.pi, forKey: "Pi")
// LOAD
let age = defaults.integer(forKey: "Age")
let useTouchID = defaults.bool(forKey: "UseTouchID")
let pi = defaults.double(forKey: "Pi")
🚀 REFERENCE
반응형
댓글