I’m trying to run an AppleScript in my SwiftUI button. But i’m not sure on how to do it? The project is for macOS.
Applescript in SwiftUI
There’s two parts to this:
-
Setting up a button in SwiftUI such that your code is called when the user clicks the button.
-
Running an AppleScript from your code.
Which bit are you having problems with?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Me 2
In my case, I don't know how to run AppleScript
I don't know how to run AppleScript
There are multiple ways to do this but the most common are:
-
NSAppleScript
-
NSUserScriptTask
, or the specificNSUserAppleScriptTask
The second is most commonly used to support script attachment in sandboxed apps.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"