Removes force unwrapping and returns an empty string if the pubDate cannot be determined.
This commit is contained in:
Stuart Breckenridge 2021-04-13 12:00:50 +08:00
parent d418835086
commit 307b24af1b
No known key found for this signature in database
GPG Key ID: ED2F112EEA9EF8A5

View File

@ -65,6 +65,10 @@ struct ArticleItemView: View {
displayFormatter.dateStyle = .medium
displayFormatter.timeStyle = .none
return displayFormatter.string(from: date!)
guard let dateFromDateFormatter = date else {
return ""
}
return displayFormatter.string(from: dateFromDateFormatter)
}
}