Fix crash when accessing SegmentedPageViewController before it's loaded

This commit is contained in:
Shadowfacts 2022-12-31 16:46:00 -05:00
parent 79b9108a8f
commit 358d81b5cf
2 changed files with 3 additions and 3 deletions

View File

@ -85,7 +85,7 @@ class TimelinesPageViewController: SegmentedPageViewController<TimelinesPageView
} }
func stateRestorationActivity() -> NSUserActivity? { func stateRestorationActivity() -> NSUserActivity? {
return (currentViewController as! TimelineViewController).stateRestorationActivity() return (currentViewController as? TimelineViewController)?.stateRestorationActivity()
} }
func restoreActivity(_ activity: NSUserActivity) { func restoreActivity(_ activity: NSUserActivity) {

View File

@ -23,8 +23,8 @@ class SegmentedPageViewController<Page: SegmentedPageViewControllerPage>: UIPage
var currentIndex: Int! { var currentIndex: Int! {
pages.firstIndex(of: currentPage) pages.firstIndex(of: currentPage)
} }
var currentViewController: UIViewController { var currentViewController: UIViewController! {
viewControllers!.first! viewControllers?.first
} }
let segmentedControl = ScrollingSegmentedControl<Page>() let segmentedControl = ScrollingSegmentedControl<Page>()