Add support for serializing `NSFontDescriptor` and `UIFontDescriptor`

This commit is contained in:
Sindre Sorhus 2024-04-20 16:20:10 +07:00
parent ce45591c09
commit 23e0a4497e
2 changed files with 14 additions and 5 deletions

View File

@ -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 {}

View File

@ -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]>]]`.