From dd39e3a0fe01e86b641f7848c034ce79746468f6 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 12 Mar 2019 21:52:21 -0700 Subject: [PATCH] Delete unused code in Author. --- Frameworks/Articles/Author.swift | 50 -------------------------------- 1 file changed, 50 deletions(-) diff --git a/Frameworks/Articles/Author.swift b/Frameworks/Articles/Author.swift index e32fe3ea7..53724e229 100644 --- a/Frameworks/Articles/Author.swift +++ b/Frameworks/Articles/Author.swift @@ -17,7 +17,6 @@ public struct Author: Codable, Hashable { public let emailAddress: String? public init?(authorID: String?, name: String?, url: String?, avatarURL: String?, emailAddress: String?) { - if name == nil && url == nil && emailAddress == nil { return nil } @@ -38,41 +37,6 @@ public struct Author: Codable, Hashable { } } - public struct Key { - static let authorID = "authorID" - static let name = "name" - static let url = "url" - static let avatarURL = "avatarURL" - static let emailAddress = "emailAddress" - } - - public init?(dictionary: [String: Any]) { - - self.init(authorID: dictionary[Key.authorID] as? String, name: dictionary[Key.name] as? String, url: dictionary[Key.url] as? String, avatarURL: dictionary[Key.avatarURL] as? String, emailAddress: dictionary[Key.emailAddress] as? String) - } - - public var dictionary: [String: Any] { - - var d = [String: Any]() - - d[Key.authorID] = authorID - - if let name = name { - d[Key.name] = name - } - if let url = url { - d[Key.url] = url - } - if let avatarURL = avatarURL { - d[Key.avatarURL] = avatarURL - } - if let emailAddress = emailAddress { - d[Key.emailAddress] = emailAddress - } - - return d - } - public static func authorsWithJSON(_ jsonString: String) -> Set? { // This is JSON stored in the database, not the JSON Feed version of an author. guard let data = jsonString.data(using: .utf8) else { @@ -89,24 +53,10 @@ public struct Author: Codable, Hashable { } return nil } - - public static func authorsWithDiskArray(_ diskArray: [[String: Any]]) -> Set? { - - let authors = diskArray.compactMap { Author(dictionary: $0) } - return authors.isEmpty ? nil : Set(authors) - } } extension Set where Element == Author { - public func diskArray() -> [[String: Any]]? { - - if self.isEmpty { - return nil - } - return self.map{ $0.dictionary } - } - public func json() -> String? { let encoder = JSONEncoder() do {