Fixed metatdata

This commit is contained in:
Rasmus Krämer
2022-04-14 12:24:27 +02:00
parent 736af85855
commit 6c65c8a33e
9 changed files with 51 additions and 16 deletions
+20
View File
@@ -0,0 +1,20 @@
//
// Extensions.swift
// App
//
// Created by Rasmus Krämer on 14.04.22.
//
import Foundation
extension String: Error {}
extension Encodable {
func asDictionary() throws -> [String: Any] {
let data = try JSONEncoder().encode(self)
guard let dictionary = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
throw NSError()
}
return dictionary
}
}