diff options
| -rw-r--r-- | ios/MullvadVPN/ConnectViewController.swift | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ios/MullvadVPN/ConnectViewController.swift b/ios/MullvadVPN/ConnectViewController.swift index 8673f8a23b..44475e603b 100644 --- a/ios/MullvadVPN/ConnectViewController.swift +++ b/ios/MullvadVPN/ConnectViewController.swift @@ -24,6 +24,8 @@ protocol ConnectViewControllerDelegate: AnyObject { class ConnectViewController: UIViewController, MKMapViewDelegate, RootContainment, TunnelObserver { + private static let geoJSONSourceFileName = "countries.geo.json" + weak var delegate: ConnectViewControllerDelegate? let notificationController = NotificationController() @@ -438,11 +440,22 @@ class ConnectViewController: UIViewController, MKMapViewDelegate, RootContainmen } private func loadGeoJSONData() { - let fileURL = Bundle.main.url(forResource: "countries.geo", withExtension: "json")! - let data = try! Data(contentsOf: fileURL) + guard let fileURL = Bundle.main.url( + forResource: Self.geoJSONSourceFileName, + withExtension: nil + ) else { + logger.debug("Failed to locate \(Self.geoJSONSourceFileName) in main bundle.") + return + } - let overlays = try! GeoJSON.decodeGeoJSON(data) - mainContentView.mapView.addOverlays(overlays, level: .aboveLabels) + do { + let data = try Data(contentsOf: fileURL) + let overlays = try GeoJSON.decodeGeoJSON(data) + + mainContentView.mapView.addOverlays(overlays) + } catch { + logger.error(chainedError: AnyChainedError(error), message: "Failed to load geojson.") + } } } |
