From 6e93cc27187828888430b73e49e1d022bbcdf91d Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 10 Dec 2017 14:04:14 -0800 Subject: [PATCH] Create FeedbinSubscription struct. --- .../Account/Feedbin/FeedbinSubscription.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Frameworks/Account/Feedbin/FeedbinSubscription.swift b/Frameworks/Account/Feedbin/FeedbinSubscription.swift index ae82ab0b6..c4678bcc8 100644 --- a/Frameworks/Account/Feedbin/FeedbinSubscription.swift +++ b/Frameworks/Account/Feedbin/FeedbinSubscription.swift @@ -15,7 +15,7 @@ struct FeedbinSubscription { let subscriptionID: String let feedID: String let creationDate: Date? - let name: String + let name: String? let url: String let homePageURL: String? @@ -54,6 +54,9 @@ struct FeedbinSubscription { if let creationDateString = dictionary[Key.creationDate] as? String { self.creationDate = RSDateWithString(creationDateString) } + else { + self.creationDate = nil + } self.name = dictionary[Key.name] as? String self.homePageURL = dictionary[Key.homePageURL] as? String @@ -61,13 +64,7 @@ struct FeedbinSubscription { static func subscriptions(with array: JSONArray) -> [FeedbinSubscription]? { - let subs = array.flatMap { (jsonSubscription) -> FeedbinSubscription? in - if let dictionary = jsonSubscription as? JSONDictionary else { - return nil - } - return FeedbinSubscription(dictionary: dictionary) - } - + let subs = array.flatMap { FeedbinSubscription(dictionary: $0) } return subs.isEmpty ? nil : subs } }