aboutsummaryrefslogtreecommitdiff
path: root/foray/Scenes/ForayTableViewController.swift
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/Scenes/ForayTableViewController.swift
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 'foray/Scenes/ForayTableViewController.swift')
-rw-r--r--foray/Scenes/ForayTableViewController.swift6
1 files changed, 3 insertions, 3 deletions
diff --git a/foray/Scenes/ForayTableViewController.swift b/foray/Scenes/ForayTableViewController.swift
index 849553c..3d839a1 100644
--- a/foray/Scenes/ForayTableViewController.swift
+++ b/foray/Scenes/ForayTableViewController.swift
@@ -87,13 +87,13 @@ class ForayTableViewController: UITableViewController, Coordinated {
switch item.type {
case .item:
type = "Item"
- icon = UIImage(named: item.id)!
+ icon = UIImage(named: item.id) ?? UIImage.fromAsset(.it)
case .quest:
type = "Quest"
- icon = UIImage(named: "spy")!
+ icon = UIImage.fromAsset(.spy)
}
- let cell: ForayTableViewCell = tableView.dequeueReusableCell(withIdentifier: "ForayTableViewCell", for: indexPath) as! ForayTableViewCell
+ guard let cell = tableView.dequeueReusableCell(withIdentifier: "ForayTableViewCell", for: indexPath) as? ForayTableViewCell else { return ForayTableViewCell() }
cell.setData(name: item.name, desc: type + "ID: " + item.id, img: icon)
return cell
}