---
title: "appleEvent(withEventClass:eventID:targetDescriptor:returnID:transactionID:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsappleeventdescriptor/appleevent(witheventclass:eventid:targetdescriptor:returnid:transactionid:)"
---

# appleEvent(withEventClass:eventID:targetDescriptor:returnID:transactionID:)

Creates a descriptor that represents an Apple event, initialized according to the specified information.

## Declaration

```swift
class func appleEvent(withEventClass eventClass: AEEventClass, eventID: AEEventID, targetDescriptor: NSAppleEventDescriptor?, returnID: AEReturnID, transactionID: AETransactionID) -> NSAppleEventDescriptor
```

## Parameters

- `eventClass`: The event class to be set in the returned descriptor.
- `eventID`: The event ID to be set in the returned descriptor.
- `targetDescriptor`: A pointer to a descriptor that identifies the target application for the Apple event. Passing nil results in an Apple event descriptor that has no keyAddressAttr attribute (it is valid for an Apple event to have no target address attribute).
- `returnID`: The return ID to be set in the returned descriptor. If you pass a value of kAutoGenerateReturnID, the Apple Event Manager assigns the created Apple event a return ID that is unique to the current session. If you pass any other value, the Apple Event Manager assigns that value for the ID.
- `transactionID`: The transaction ID to be set in the returned descriptor. A transaction is a sequence of Apple events that are sent back and forth between client and server applications, beginning with the client’s initial request for a service. All Apple events that are part of a transaction must have the same transaction ID. You can specify kAnyTransactionID if the Apple event is not one of a series of interdependent Apple events.

## Return Value

Return Value A descriptor for an Apple event, initialized according to the specified parameter values, or nil if an error occurs.

## Discussion

Discussion Constants such as kAutoGenerateReturnID and kAnyTransactionID are defined in AE.framework, a subframework of ApplicationServices.framework.

## See Also

### Related Documentation

- [Cocoa Scripting Guide](apple-archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html.md)

### Creating and Initializing Descriptors

- [init(boolean:)](foundation/nsappleeventdescriptor/init(boolean:).md)
- [init(enumCode:)](foundation/nsappleeventdescriptor/init(enumcode:).md)
- [init(int32:)](foundation/nsappleeventdescriptor/init(int32:).md)
- [init(string:)](foundation/nsappleeventdescriptor/init(string:).md)
- [init(typeCode:)](foundation/nsappleeventdescriptor/init(typecode:).md)
- [list()](foundation/nsappleeventdescriptor/list().md)
- [null()](foundation/nsappleeventdescriptor/null().md)
- [record()](foundation/nsappleeventdescriptor/record().md)
- [init(listDescriptor:)](foundation/nsappleeventdescriptor/init(listdescriptor:).md)
- [init(recordDescriptor:)](foundation/nsappleeventdescriptor/init(recorddescriptor:).md)
- [init(aeDescNoCopy:)](foundation/nsappleeventdescriptor/init(aedescnocopy:)-5cioa.md)
- [init(descriptorType:bytes:length:)](foundation/nsappleeventdescriptor/init(descriptortype:bytes:length:).md)
- [init(descriptorType:data:)](foundation/nsappleeventdescriptor/init(descriptortype:data:).md)
- [init(eventClass:eventID:targetDescriptor:returnID:transactionID:)](foundation/nsappleeventdescriptor/init(eventclass:eventid:targetdescriptor:returnid:transactionid:).md)
