Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Handles nil fonts correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfurrow committed Dec 3, 2020
1 parent 071ab0f commit c461938
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Kiosk/App/Models/Artwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit c461938

Please sign in to comment.