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

# key(withAppleEventCode:)

Given an Apple event code that identifies a property or element class, returns the key for the corresponding attribute, one-to-one relationship, or one-to-many relationship.

```
func key(withAppleEventCode appleEventCode: FourCharCode) -> String?
```

## Parameters

`appleEventCode`

An Apple event code that identifies a property or element class.

## Return Value

The key that corresponds to the property or element class identified by `appleEventCode` in the receiver or, if none exists, in a class description in the receiver’s superclasses. The four-character Apple event code associated with the attribute or relationship identified by `key` Returns `0` if no such attribute or relationship is found. Returns `nil` if it cannot find any such attribute or relationship.

## See Also

[`-  isReadOnlyKey:`](/documentation/Foundation/NSScriptClassDescription/isReadOnlyKey:)

Returns a Boolean value indicating whether a specified property in the receiver is read-only.



---

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)