Skip to content

Commit

Permalink
refactor: avoid force unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
nuomi1 committed Oct 5, 2020
1 parent a25913b commit 9630a4c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Sources/SwiftDate/Supports/Commons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ public extension DateFormatter {
/// - Returns: number formatter instance
@available(iOS 9.0, macOS 10.11, *)
static func sharedOrdinalNumberFormatter(locale: LocaleConvertible) -> NumberFormatter {
var formatter: NumberFormatter?
let name = "SwiftDate_\(NSStringFromClass(NumberFormatter.self))"
formatter = threadSharedObject(key: name, create: { return NumberFormatter() })
formatter!.numberStyle = .ordinal
formatter!.locale = locale.toLocale()
return formatter!
let formatter = threadSharedObject(key: name, create: { return NumberFormatter() })
formatter.numberStyle = .ordinal
formatter.locale = locale.toLocale()
return formatter
}

}
Expand Down

0 comments on commit 9630a4c

Please sign in to comment.