summaryrefslogtreecommitdiffstats
path: root/osdep/mac/swift_extensions.swift
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/mac/swift_extensions.swift')
-rw-r--r--osdep/mac/swift_extensions.swift5
1 files changed, 3 insertions, 2 deletions
diff --git a/osdep/mac/swift_extensions.swift b/osdep/mac/swift_extensions.swift
index 2399c86509..e49806aaa0 100644
--- a/osdep/mac/swift_extensions.swift
+++ b/osdep/mac/swift_extensions.swift
@@ -32,8 +32,9 @@ extension NSScreen {
}
public var name: String {
- // force unwrapping is fine here, regex is guaranteed to be valid
- let regex = try! NSRegularExpression(pattern: " \\(\\d+\\)$", options: .caseInsensitive)
+ guard let regex = try? NSRegularExpression(pattern: " \\(\\d+\\)$", options: .caseInsensitive) else {
+ return localizedName
+ }
return regex.stringByReplacingMatches(
in: localizedName,
range: NSRange(location: 0, length: localizedName.count),