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/Presenters | |
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 'foray/Presenters')
-rw-r--r-- | foray/Presenters/PenguinItemPresenter.swift | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/foray/Presenters/PenguinItemPresenter.swift b/foray/Presenters/PenguinItemPresenter.swift index 1d617bf..45b970c 100644 --- a/foray/Presenters/PenguinItemPresenter.swift +++ b/foray/Presenters/PenguinItemPresenter.swift @@ -16,12 +16,9 @@ class PenguinItemPresenter { let fetcher = ForayFetcher() func fetch() async -> [PenguinItemViewModel] { - do { - let apiItems: [PenguinItemModel] = try await fetcher.fetch(url: Constants.apiEndpoint) - return transform(models: apiItems) - } catch { - return [] - } + guard let endpoint = URL(string: Constants.apiEndpoint), + let apiItems: [PenguinItemModel] = try? await fetcher.fetch(url: endpoint) else { return [] } + return transform(models: apiItems) } func transform(models: [PenguinItemModel]) -> [PenguinItemViewModel] { |