diff --git a/Sources/Defaults/Defaults.swift b/Sources/Defaults/Defaults.swift index c87b56f..eca307c 100644 --- a/Sources/Defaults/Defaults.swift +++ b/Sources/Defaults/Defaults.swift @@ -46,7 +46,9 @@ public enum Defaults { /** Create a defaults key. - The `default` parameter can be left out if the `Value` type is an optional. + - Parameter key: The key 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. */ public init(_ key: String, default defaultValue: Value, suite: UserDefaults = .standard) { self.defaultValue = defaultValue @@ -86,6 +88,11 @@ extension Defaults { } extension Defaults.Key { + /** + Create a defaults key. + + - Parameter key: The key must be ASCII, not start with `@`, and cannot contain a dot (`.`). + */ public convenience init(_ key: String, suite: UserDefaults = .standard) where Value == T? { self.init(key, default: nil, suite: suite) } diff --git a/readme.md b/readme.md index 6c19bf0..d8f75e4 100644 --- a/readme.md +++ b/readme.md @@ -80,7 +80,7 @@ If a type conforms to both `NSSecureCoding` and `Codable`, then `Codable` will b You declare the defaults keys upfront with type and default value. -**Do not use a dot in the key name, because of [this bug](https://github.com/sindresorhus/Defaults/issues/59).** +**The key name must be ASCII, not start with `@`, and cannot contain a dot (`.`).** ```swift import Cocoa