aboutsummaryrefslogtreecommitdiff
path: root/foray/Extensions
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-07-17 02:25:12 +1000
committerNicholas Tay <nick@windblume.net>2022-07-17 02:25:12 +1000
commitbd7761216a065b0dd859cb19d709996739a240cd (patch)
tree8b1d33034f8c212613d7a07b864d1688b8c080d2 /foray/Extensions
parent1adbed9f8b94521befd237c14d36325a55037a41 (diff)
downloadforayios-bd7761216a065b0dd859cb19d709996739a240cd.tar.gz
forayios-bd7761216a065b0dd859cb19d709996739a240cd.tar.bz2
forayios-bd7761216a065b0dd859cb19d709996739a240cd.zip
Clean up force unwraps and lets
Wow, I didn't know `if let` was a thing back then, haha. Also made UIImage a bit safer in case asset is missing by unwrapping in one common place.
Diffstat (limited to '')
-rw-r--r--foray/Extensions/UIImage+Extensions.swift21
1 files changed, 21 insertions, 0 deletions
diff --git a/foray/Extensions/UIImage+Extensions.swift b/foray/Extensions/UIImage+Extensions.swift
new file mode 100644
index 0000000..252c3fb
--- /dev/null
+++ b/foray/Extensions/UIImage+Extensions.swift
@@ -0,0 +1,21 @@
+//
+// UIImage+Extensions.swift
+// foray
+//
+// Created by Nicholas Tay on 17/7/2022.
+//
+
+import UIKit
+
+extension UIImage {
+ static func fromAsset(_ assetImage: AssetImage) -> UIImage {
+ return UIImage(named: assetImage.rawValue)!
+ }
+}
+
+/// Known asset images that we can safely unwrap
+enum AssetImage: String {
+ case AppIcon
+ case it
+ case spy
+}