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

# type(forKey:)

Returns the name of the declared type of the attribute or relationship identified by the passed key.

## Declaration

```swift
func type(forKey key: String) -> String?
```

## Parameters

- `key`: The identifying key for an attribute, one-to-one relationship, or one-to-many relationship of the receiver.

## Return Value

Return Value The name of the declared type of the attribute or relationship identified by key; for example, “NSString”. Searches in the receiver first, then in any superclass. Returns nil if no match is found.

## 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)
- [key(withAppleEventCode:)](foundation/nsscriptclassdescription/key(withappleeventcode:).md)
