aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/Application.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-25 18:42:51 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:29 +0530
commit5c7a149167802902c1632b8062df2969f4680b04 (patch)
tree3df44642568ceef663f17f13d9e4805256a94a6f /WireGuard/WireGuard/UI/macOS/Application.swift
parentmacOS: NE: Add entitlements for making network connections (diff)
downloadwireguard-apple-5c7a149167802902c1632b8062df2969f4680b04.tar.xz
wireguard-apple-5c7a149167802902c1632b8062df2969f4680b04.zip
macOS: Remove MainMenu.xib
When there's no xib, we should explicitly set the app delegate, so we override NSApplication and set the app delegate in NSApplication.shared Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/Application.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/Application.swift17
1 files changed, 17 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/Application.swift b/WireGuard/WireGuard/UI/macOS/Application.swift
new file mode 100644
index 0000000..9f7b810
--- /dev/null
+++ b/WireGuard/WireGuard/UI/macOS/Application.swift
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018 WireGuard LLC. All Rights Reserved.
+
+import Cocoa
+
+var appDelegate: AppDelegate?
+
+class Application: NSApplication {
+ // We use a custom Application class to be able to set the app delegate
+ // before app.run() gets called in NSApplicationMain().
+ override class var shared: NSApplication {
+ let app = NSApplication.shared
+ appDelegate = AppDelegate() // Keep a strong reference to the app delegate
+ app.delegate = appDelegate
+ return app
+ }
+}