<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAppleScript/executeAppleEvent(_:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAppleScript(im)executeAppleEvent:error:"
  },
  "title" : "executeAppleEvent(_:error:)"
}
-->

# executeAppleEvent(_:error:)

Executes an Apple event in the context of the receiver, as a means of allowing the application to invoke a handler in the script.

```
func executeAppleEvent(_ event: NSAppleEventDescriptor, error errorInfo: AutoreleasingUnsafeMutablePointer<NSDictionary?>?) -> NSAppleEventDescriptor
```

## Parameters

`event`

The Apple event to execute.

`errorInfo`

On return, if an error occurs, a pointer to an error information dictionary.

## Return Value

The result of executing the event, or `nil` if an error occurs.

## Discussion

Compiles the receiver before executing it if it is not already compiled.

> Important:
> You cannot use this method to send Apple events to other applications.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)