Fix CI
Swifty and modern UserDefaults
Store key-value pairs persistently across launches of your app.
It uses UserDefaults underneath but exposes a type-safe facade with lots of nice conveniences.
UserDefaults
It’s used in production by all my apps (4 million+ users).
@AppStorage
Codable
Toggle
Add https://github.com/sindresorhus/Defaults in the “Swift Package Manager” tab in Xcode.
https://github.com/sindresorhus/Defaults
Full documentation
import Defaults extension Defaults.Keys { static let quality = Key<Double>("quality", default: 0.8) } Defaults[.quality] //=> 0.8 Defaults[.quality] = 0.5 //=> 0.5
You can also use it in SwiftUI:
struct ContentView: View { @Default(.quality) var quality var body: some View { Slider(value: $quality, in: 0...1) } }
Swifty and modern UserDefaults. https://swiftpackageindex.com/sindresorhus/Defaults/v8.2.0/documentation/defaults
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Defaults
Store key-value pairs persistently across launches of your app.
It uses
UserDefaultsunderneath but exposes a type-safe facade with lots of nice conveniences.It’s used in production by all my apps (4 million+ users).
Highlights
UserDefaultsvalue changes.Benefits over
@AppStorageCodable.Togglecomponent.Compatibility
Install
Add
https://github.com/sindresorhus/Defaultsin the “Swift Package Manager” tab in Xcode.Documentation
Full documentation
Usage
You can also use it in SwiftUI:
Maintainers
Related