diff options
author | Nicholas Tay <nick@windblume.net> | 2022-07-17 02:25:12 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-07-17 02:25:12 +1000 |
commit | bd7761216a065b0dd859cb19d709996739a240cd (patch) | |
tree | 8b1d33034f8c212613d7a07b864d1688b8c080d2 /foray/Extensions | |
parent | 1adbed9f8b94521befd237c14d36325a55037a41 (diff) | |
download | forayios-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.swift | 21 |
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 +} |