---
title: "AEDecodeMessage(_:_:_:)"
framework: coreservices
role: symbol
role_heading: Function
path: coreservices/1447827-aedecodemessage
---

# AEDecodeMessage(_:_:_:)

Decodes a Mach message and converts it into an Apple event and its related reply.

## Declaration

```swift
func AEDecodeMessage(_ header: UnsafeMutablePointer<mach_msg_header_t>!, _ event: UnsafeMutablePointer<AppleEvent>!, _ reply: UnsafeMutablePointer<AppleEvent>!) -> OSStatus
```

## Parameters

- `header`: A pointer to a Mach message header for the event to be decoded.
- `event`: A pointer to a null Apple event descriptor (one with descriptor type typeNull). On successful completion, contains the decoded Apple event. If the function returns successfully, your application should call the doc://com.apple.documentation/documentation/coreservices/1444208-aedisposedesc function to dispose of the resulting descriptor after it has finished using it.
- `reply`: A pointer to a null Apple event descriptor. On successful completion, contains the reply event from the decoded Apple event. To send the reply, you use the following: AESendMessage(reply, NULL, kAENoReply, kAEDefaultTimeout);

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion The Apple Event Manager provides the following functions (in macOS only) for working with Apple events at a lower level: AEGetRegisteredMachPort(), AEDecodeMessage, AESendMessage(_:_:_:_:), and AEProcessMessage(_:). See the descriptions for those functions for more information on when you might use them.

## See Also

### Working With Lower Level Apple Event Functions

- [AEGetRegisteredMachPort()](coreservices/1449736-aegetregisteredmachport.md)
- [AESendMessage(_:_:_:_:)](coreservices/1442994-aesendmessage.md)
- [AEProcessMessage(_:)](coreservices/1444387-aeprocessmessage.md)
