---
title: "key(withAppleEventCode:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsscriptclassdescription/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.

## Declaration

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

## Parameters

- `appleEventCode`: An Apple event code that identifies a property or element class.

## Return Value

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

### Getting attribute and relationship information

- [hasOrderedToManyRelationship(forKey:)](foundation/nsscriptclassdescription/hasorderedtomanyrelationship(forkey:).md)
- [hasProperty(forKey:)](foundation/nsscriptclassdescription/hasproperty(forkey:).md)
- [hasReadableProperty(forKey:)](foundation/nsscriptclassdescription/hasreadableproperty(forkey:).md)
- [hasWritableProperty(forKey:)](foundation/nsscriptclassdescription/haswritableproperty(forkey:).md)
- [type(forKey:)](foundation/nsscriptclassdescription/type(forkey:).md)
