From 23e0a4497e844db64e12740e2ab4a632857d3de6 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 20 Apr 2024 16:20:10 +0700 Subject: [PATCH] Add support for serializing `NSFontDescriptor` and `UIFontDescriptor` --- Sources/Defaults/Defaults+Extensions.swift | 6 ++++++ readme.md | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/Defaults/Defaults+Extensions.swift b/Sources/Defaults/Defaults+Extensions.swift index 61caa69..3c75ab5 100644 --- a/Sources/Defaults/Defaults+Extensions.swift +++ b/Sources/Defaults/Defaults+Extensions.swift @@ -168,6 +168,12 @@ extension NSColor: Defaults.Serializable {} extension UIColor: Defaults.Serializable {} #endif +#if os(macOS) +extension NSFontDescriptor: Defaults.Serializable {} +#else +extension UIFontDescriptor: Defaults.Serializable {} +#endif + extension NSUbiquitousKeyValueStore: DefaultsKeyValueStore {} extension UserDefaults: DefaultsKeyValueStore {} diff --git a/readme.md b/readme.md index 7566f17..1052269 100644 --- a/readme.md +++ b/readme.md @@ -54,13 +54,16 @@ Add `https://github.com/sindresorhus/Defaults` in the [“Swift Package Manager - `Data` - `URL` - `UUID` -- `NSColor` (macOS) -- `UIColor` (iOS) -- `Color` [^1] (SwiftUI) -- `Color.Resolved` [^1] (SwiftUI) +- `Range` +- `ClosedRange` - `Codable` - `NSSecureCoding` -- `Range`, `ClosedRange` +- `Color` [^1] (SwiftUI) +- `Color.Resolved` [^1] (SwiftUI) +- `NSColor` +- `UIColor` +- `NSFontDescriptor` +- `UIFontDescriptor` Defaults also support the above types wrapped in `Array`, `Set`, `Dictionary`, `Range`, `ClosedRange`, and even wrapped in nested types. For example, `[[String: Set<[String: Int]>]]`.