---
title: "appleEventCode(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsscriptclassdescription/appleeventcode(forkey:)"
---

# appleEventCode(forKey:)

Returns the Apple event code for the specified attribute or relationship in the receiver.

## Declaration

```swift
func appleEventCode(forKey key: String) -> FourCharCode
```

## Parameters

- `key`: The identifying key for an attribute or relationship of the receiver.

## Return Value

Return Value The four-character Apple event code associated with the attribute or relationship identified by key in the receiver or, if none exists, in the class description for the receiver’s superclass. Returns 0 if no such attribute or relationship is found.

## See Also

### Getting and comparing Apple event codes

- [appleEventCode](foundation/nsscriptclassdescription/appleeventcode.md)
- [matchesAppleEventCode(_:)](foundation/nsscriptclassdescription/matchesappleeventcode(_:).md)
