<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAppleEventDescriptor/descriptorWithDescriptorType:data:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAppleEventDescriptor(cm)descriptorWithDescriptorType:data:"
  },
  "title" : "descriptorWithDescriptorType:data:"
}
-->

# descriptorWithDescriptorType:data:

Creates a descriptor initialized with the specified event type that stores the specified data (from an instance of `NSData`).

```
+ (NSAppleEventDescriptor *) descriptorWithDescriptorType:(DescType) descriptorType data:(NSData *) data;
```

## Parameters

`descriptorType`

The descriptor type to be set in the returned descriptor.

`data`

The data, as an instance of `NSData`, to be set in the returned descriptor.

## Return Value

A descriptor with the specified type and data, or `nil` if an error occurs.

## Discussion

You can use this method to create a descriptor that you can build into a complete Apple event by calling methods such as [`setAttribute(_:forKeyword:)`](/documentation/Foundation/NSAppleEventDescriptor/setAttribute(_:forKeyword:)), [`setDescriptor(_:forKeyword:)`](/documentation/Foundation/NSAppleEventDescriptor/setDescriptor(_:forKeyword:)), and [`setParam(_:forKeyword:)`](/documentation/Foundation/NSAppleEventDescriptor/setParam(_:forKeyword:)).

---

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)