Import: Support for opening a .conf file in the app

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-10-25 11:10:18 +05:30
parent 112b5c3b10
commit 05b9d6972b
4 changed files with 67 additions and 6 deletions
+19 -1
View File
@@ -2,11 +2,13 @@
// Copyright © 2018 WireGuard LLC. All rights reserved.
import UIKit
import os.log
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var mainVC: MainViewController?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
@@ -15,9 +17,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window.backgroundColor = UIColor.white
self.window = window
window.rootViewController = MainViewController()
let mainVC = MainViewController()
window.rootViewController = mainVC
window.makeKeyAndVisible()
self.mainVC = mainVC
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
// Based on importing code by Jeroen Leenarts <jeroen.leenarts@gmail.com> in commit 815f12c
defer {
do {
try FileManager.default.removeItem(at: url)
} catch {
os_log("Failed to remove item from Inbox: %{public}@", log: OSLog.default, type: .debug, url.absoluteString)
}
}
mainVC?.openForEditing(configFileURL: url)
return true
}
}