Skip to content

Commit

Permalink
Add support for serializing NSFontDescriptor and UIFontDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 20, 2024
1 parent ce45591 commit 23e0a44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Sources/Defaults/Defaults+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
13 changes: 8 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>]]`.

Expand Down

0 comments on commit 23e0a44

Please sign in to comment.