From d71bfd8ffbf944ef08eacbca5fb96d6f69bf7696 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 8 Dec 2022 19:15:16 +0100 Subject: [PATCH] Minor tweaks --- Sources/Defaults/Defaults.swift | 18 +++++++++--------- readme.md | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/Defaults/Defaults.swift b/Sources/Defaults/Defaults.swift index 09b94b8..a14ca85 100644 --- a/Sources/Defaults/Defaults.swift +++ b/Sources/Defaults/Defaults.swift @@ -102,19 +102,19 @@ extension Defaults { /** Create a key. - - Parameter key: The key must be ASCII, not start with `@`, and cannot contain a dot (`.`). + - Parameter name: The name must be ASCII, not start with `@`, and cannot contain a dot (`.`). The `default` parameter should not be used if the `Value` type is an optional. */ @_alwaysEmitIntoClient public init( - _ key: String, + _ name: String, default defaultValue: Value, suite: UserDefaults = .standard ) { self.defaultValueGetter = { defaultValue } - super.init(name: key, suite: suite) + super.init(name: name, suite: suite) if (defaultValue as? _DefaultsOptionalProtocol)?.isNil == true { return @@ -139,19 +139,19 @@ extension Defaults { } ``` - - Parameter key: The key must be ASCII, not start with `@`, and cannot contain a dot (`.`). + - Parameter name: The name must be ASCII, not start with `@`, and cannot contain a dot (`.`). - Note: This initializer will not set the default value in the actual `UserDefaults`. This should not matter much though. It's only really useful if you use legacy KVO bindings. */ @_alwaysEmitIntoClient public init( - _ key: String, + _ name: String, suite: UserDefaults = .standard, default defaultValueGetter: @escaping () -> Value ) { self.defaultValueGetter = defaultValueGetter - super.init(name: key, suite: suite) + super.init(name: name, suite: suite) } } } @@ -161,14 +161,14 @@ extension Defaults.Key { /** Create a key with an optional value. - - Parameter key: The key must be ASCII, not start with `@`, and cannot contain a dot (`.`). + - Parameter name: The name must be ASCII, not start with `@`, and cannot contain a dot (`.`). */ @_transparent public convenience init( - _ key: String, + _ name: String, suite: UserDefaults = .standard ) where Value == T? { - self.init(key, default: nil, suite: suite) + self.init(name, default: nil, suite: suite) } } diff --git a/readme.md b/readme.md index 3f6d5a1..eb14051 100644 --- a/readme.md +++ b/readme.md @@ -347,7 +347,7 @@ Stores the keys. #### `Defaults.Key` _(alias `Defaults.Keys.Key`)_ ```swift -Defaults.Key(_ key: String, default: T, suite: UserDefaults = .standard) +Defaults.Key(_ name: String, default: T, suite: UserDefaults = .standard) ``` Type: `class`