From c461938420b54b3554c9f9f625fdac7e6194b15d Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Thu, 3 Dec 2020 12:09:11 -0400 Subject: [PATCH] Handles nil fonts correctly. --- Kiosk/App/Models/Artwork.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kiosk/App/Models/Artwork.swift b/Kiosk/App/Models/Artwork.swift index 4f8b09c9..d8cd748a 100644 --- a/Kiosk/App/Models/Artwork.swift +++ b/Kiosk/App/Models/Artwork.swift @@ -94,12 +94,12 @@ import SwiftyJSON private func titleAndDateAttributedString(_ title: String, dateString: String) -> NSAttributedString { let workTitle = title.isEmpty ? "Untitled" : title - let workFont = UIFont.serifItalicFont(withSize: 16)! - let attributedString = NSMutableAttributedString(string: workTitle, attributes: [NSAttributedStringKey.font : workFont]) + let workFont: UIFont? = UIFont.serifItalicFont(withSize: 16) + let attributedString = NSMutableAttributedString(string: workTitle, attributes: workFont == nil ? nil : [NSAttributedStringKey.font : workFont!]) if dateString.isNotEmpty { - let dateFont = UIFont.serifFont(withSize: 16)! - let dateString = NSAttributedString(string: ", " + dateString, attributes: [NSAttributedStringKey.font : dateFont]) + let dateFont: UIFont? = UIFont.serifFont(withSize: 16) + let dateString = NSAttributedString(string: ", " + dateString, attributes: dateFont == nil ? nil : [NSAttributedStringKey.font : dateFont!]) attributedString.append(dateString) }