NetNewsWire/Frameworks/Database/Extensions/Author+Database.swift

40 lines
938 B
Swift
Raw Normal View History

2017-07-11 05:54:00 +02:00
//
// Author+Database.swift
// Database
//
// Created by Brent Simmons on 7/8/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
extension Author {
private static let
convenience init?(databaseDictionary d: [String: Any]) {
guard let url = d[DatabaseKey.url] as? String else {
return nil
}
let mimeType = d[DatabaseKey.mimeType] as? String
let title = d[DatabaseKey.title] as? String
let durationInSeconds = d[DatabaseKey.durationInSeconds] as? Int
self.init(url: url, mimeType: mimeType, title: title, durationInSeconds: durationInSeconds)
self.init(name: name, url: url, avatarURL: avatarURL, emailAddress: emailAddress)
}
class func attachments(with plist: [Any]) -> [Attachment]? {
return plist.flatMap{ (oneDictionary) -> Attachment? in
if let d = oneDictionary as? [String: Any] {
return Attachment(databaseDictionary: d)
}
return nil
}
}
}