Update readme.md

This commit is contained in:
Sindre Sorhus 2020-01-09 17:39:31 +07:00 committed by GitHub
parent 55ffea9487
commit a2e2be2d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -2,8 +2,9 @@
> Swifty and modern [UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults) > Swifty and modern [UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults)
This package is used in production by apps like [Gifski](https://github.com/sindresorhus/Gifski), [Dato](https://sindresorhus.com/dato), [Lungo](https://sindresorhus.com/lungo), [Battery Indicator](https://sindresorhus.com/battery-indicator), and [HEIC Converter](https://sindresorhus.com/heic-converter). It uses `NSUserDefaults` underneath but exposes a type-safe facade with lots of nice conveniences.
It's used in production by apps like [Gifski](https://github.com/sindresorhus/Gifski), [Dato](https://sindresorhus.com/dato), [Lungo](https://sindresorhus.com/lungo), [Battery Indicator](https://sindresorhus.com/battery-indicator), and [HEIC Converter](https://sindresorhus.com/heic-converter).
## Highlights ## Highlights
@ -14,7 +15,6 @@ This package is used in production by apps like [Gifski](https://github.com/sind
- **Observation:** Observe changes to keys. - **Observation:** Observe changes to keys.
- **Lightweight:** It's only some hundred lines of code. - **Lightweight:** It's only some hundred lines of code.
## Compatibility ## Compatibility
- macOS 10.12+ - macOS 10.12+
@ -22,7 +22,6 @@ This package is used in production by apps like [Gifski](https://github.com/sind
- tvOS 10+ - tvOS 10+
- watchOS 3+ - watchOS 3+
## Install ## Install
#### SwiftPM #### SwiftPM
@ -43,7 +42,6 @@ github "sindresorhus/Defaults"
pod 'Defaults' pod 'Defaults'
``` ```
## Usage ## Usage
You declare the defaults keys upfront with type and default value. You declare the defaults keys upfront with type and default value.
@ -248,7 +246,6 @@ print(UserDefaults.standard.bool(forKey: isUnicornMode.name))
//=> true //=> true
``` ```
## API ## API
### `Defaults` ### `Defaults`
@ -412,14 +409,12 @@ Break the lifetime tie created by `tieToLifetime(of:)`, if one exists.
The effects of any call to `tieToLifetime(of:)` are reversed. Note however that if the tied-to object has already died, then the observation is already invalid and this method has no logical effect. The effects of any call to `tieToLifetime(of:)` are reversed. Note however that if the tied-to object has already died, then the observation is already invalid and this method has no logical effect.
## FAQ ## FAQ
### How is this different from [`SwiftyUserDefaults`](https://github.com/radex/SwiftyUserDefaults)? ### How is this different from [`SwiftyUserDefaults`](https://github.com/radex/SwiftyUserDefaults)?
It's inspired by that package and other solutions. The main difference is that this module doesn't hardcode the default values and comes with Codable support. It's inspired by that package and other solutions. The main difference is that this module doesn't hardcode the default values and comes with Codable support.
## Related ## Related
- [Preferences](https://github.com/sindresorhus/Preferences) - Add a preferences window to your macOS app in minutes - [Preferences](https://github.com/sindresorhus/Preferences) - Add a preferences window to your macOS app in minutes