From 00c07377ed2ee21b75102485617cd17c92653c68 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Mon, 24 Dec 2018 12:58:35 +0530 Subject: [PATCH] Tunnel edit: Fix crash This fixes a crash that happens when you: 1. Scroll to the end of the Edit screen 2. Delete a peer 3. Toggle the Activate On Demand switch --- .../UI/iOS/ViewController/TunnelEditTableViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift index 6fc0646..a8d504e 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift @@ -417,7 +417,8 @@ extension TunnelEditTableViewController { self.activateOnDemandSetting.isActivateOnDemandEnabled = isOn self.loadSections() - let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: indexPath.section) } + let section = self.sections.firstIndex(where: { $0 == .onDemand })! + let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: section) } if isOn { if self.activateOnDemandSetting.activateOnDemandOption == .none { self.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption()