From c99a724bf3f6dc60fe7669c323d1b3e965a46f60 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 20 Jan 2020 11:18:55 -0500 Subject: [PATCH] Fix instance public timelines crashing The instance timeline controller needs to store a strong reference to the instance-specific MastodonController since the timeline VC only holds a weak reference, and unlike normal screens, the scene session doesn't hold onto the MastodonController for other instances. --- .../Screens/Timeline/InstanceTimelineViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Timeline/InstanceTimelineViewController.swift b/Tusker/Screens/Timeline/InstanceTimelineViewController.swift index d5c1943036..bd249a802a 100644 --- a/Tusker/Screens/Timeline/InstanceTimelineViewController.swift +++ b/Tusker/Screens/Timeline/InstanceTimelineViewController.swift @@ -18,6 +18,7 @@ class InstanceTimelineViewController: TimelineTableViewController { weak var delegate: InstanceTimelineViewControllerDelegate? let instanceURL: URL + let instanceMastodonController: MastodonController var toggleSaveButton: UIBarButtonItem! var toggleSaveButtonTitle: String { @@ -31,9 +32,10 @@ class InstanceTimelineViewController: TimelineTableViewController { init(for url: URL) { self.instanceURL = url - let mastodonController = MastodonController(instanceURL: url) + // the timeline VC only stores a weak reference to it, so we need to store a strong reference to make sure it's not released immediately + instanceMastodonController = MastodonController(instanceURL: url) - super.init(for: .instance(instanceURL: url), mastodonController: mastodonController) + super.init(for: .instance(instanceURL: url), mastodonController: instanceMastodonController) } required init?(coder aDecoder: NSCoder) {