---
title: "descriptorWithDescriptorType:data:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsappleeventdescriptor/descriptorwithdescriptortype:data:"
---

# descriptorWithDescriptorType:data:

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

## Declaration

```occ
+ (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

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

## Discussion

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:), setDescriptor(_:forKeyword:), and setParam(_:forKeyword:).

## See Also

### Creating and Initializing Descriptors

- [appleEvent(withEventClass:eventID:targetDescriptor:returnID:transactionID:)](foundation/nsappleeventdescriptor/appleevent(witheventclass:eventid:targetdescriptor:returnid:transactionid:).md)
- [init(boolean:)](foundation/nsappleeventdescriptor/init(boolean:).md)
- [descriptorWithDescriptorType:bytes:length:](foundation/nsappleeventdescriptor/descriptorwithdescriptortype:bytes:length:.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)
