From c63303f05a651b04718469b7abcdd7c7e5ca1de6 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 15 Jan 2018 12:10:57 -0800 Subject: [PATCH] Add UserApp.targetDescriptor. --- Frameworks/RSCore/RSCore/AppKit/UserApp.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Frameworks/RSCore/RSCore/AppKit/UserApp.swift b/Frameworks/RSCore/RSCore/AppKit/UserApp.swift index 00a71c55e..164192ad8 100644 --- a/Frameworks/RSCore/RSCore/AppKit/UserApp.swift +++ b/Frameworks/RSCore/RSCore/AppKit/UserApp.swift @@ -118,6 +118,18 @@ public final class UserApp { updateStatus() return runningApplication?.activate(options: [.activateIgnoringOtherApps]) ?? false } + + public func targetDescriptor() -> NSAppleEventDescriptor? { + + // Requires that the app has previously been launched. + + updateStatus() + guard let runningApplication = runningApplication, !runningApplication.isTerminated else { + return nil + } + + return NSAppleEventDescriptor(runningApplication: runningApplication) + } }