From: Roopesh Chander Date: Mon, 20 May 2019 10:56:02 +0000 (+0530) Subject: macOS: Simplify detecting the type of an Apple event X-Git-Tag: 0.0.20190531-9~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d19691a7d9c24fd968801f1721010a67399d06;p=thirdparty%2Fwireguard-apple.git macOS: Simplify detecting the type of an Apple event Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift b/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift index 53a4dae..185aced 100644 --- a/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift +++ b/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift @@ -13,9 +13,5 @@ class LaunchedAtLoginDetector { } private func isOpenEvent(_ event: NSAppleEventDescriptor) -> Bool { - if let eventClassDescriptor = event.attributeDescriptor(forKeyword: keyEventClassAttr), - let eventIdDescriptor = event.attributeDescriptor(forKeyword: keyEventIDAttr) { - return eventClassDescriptor.typeCodeValue == kCoreEventClass && eventIdDescriptor.typeCodeValue == kAEOpenApplication - } - return false + return event.eventClass == kCoreEventClass && event.eventID == kAEOpenApplication } diff --git a/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift b/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift index 7fbb011..68608ca 100644 --- a/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift +++ b/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift @@ -19,11 +19,7 @@ class MacAppStoreUpdateDetector { } private func isQuitEvent(_ event: NSAppleEventDescriptor) -> Bool { - if let eventClassDescriptor = event.attributeDescriptor(forKeyword: keyEventClassAttr), - let eventIdDescriptor = event.attributeDescriptor(forKeyword: keyEventIDAttr) { - return eventClassDescriptor.typeCodeValue == kCoreEventClass && eventIdDescriptor.typeCodeValue == kAEQuitApplication - } - return false + return event.eventClass == kCoreEventClass && event.eventID == kAEQuitApplication } private func getExecutablePath(from pid: pid_t) -> String? {