diff options
author | Nicholas Tay <nick@windblume.net> | 2022-07-17 01:56:43 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-07-17 01:56:43 +1000 |
commit | daee1f1b5c739f42ba54a1ebbb9655f5034e315f (patch) | |
tree | dfeb6550b4c97e16c81fa589c8d113ffef599d92 /foray/Presenters | |
parent | 13f60899394f3bda4b77e6d5dc71f418ad0e2975 (diff) | |
download | forayios-daee1f1b5c739f42ba54a1ebbb9655f5034e315f.tar.gz forayios-daee1f1b5c739f42ba54a1ebbb9655f5034e315f.tar.bz2 forayios-daee1f1b5c739f42ba54a1ebbb9655f5034e315f.zip |
'weak self' stuff
Diffstat (limited to 'foray/Presenters')
-rw-r--r-- | foray/Presenters/PenguinItemPresenter.swift | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/foray/Presenters/PenguinItemPresenter.swift b/foray/Presenters/PenguinItemPresenter.swift index 698b56e..c4553ae 100644 --- a/foray/Presenters/PenguinItemPresenter.swift +++ b/foray/Presenters/PenguinItemPresenter.swift @@ -12,11 +12,12 @@ class PenguinItemPresenter { let fetcher = ForayFetcher() func fetch(receiver: @escaping ([PenguinItemViewModel]) -> ()) { - fetcher.fetch(url: "https://users.windblume.net/~nick/upload/dummy.json") { (apiItems: [PenguinItemModel]) in + fetcher.fetch(url: "https://users.windblume.net/~nick/upload/dummy.json") { [weak self] (apiItems: [PenguinItemModel]) in // Callback to main thread here // There probably is a nicer way to do it, but we will DispatchQueue it back // from the Presenter-level for now (main thread from VC onwards) DispatchQueue.main.async { + guard let self = self else { return } receiver(self.transform(models: apiItems)) } } |