<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSCustomAttributeKey",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Spotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSCustomAttributeKey"
  },
  "title" : "CSCustomAttributeKey"
}
-->

# CSCustomAttributeKey

A key associated with a custom attribute for a searchable item.

```
class CSCustomAttributeKey
```

## Overview

The `CSCustomAttributeKey` class defines a key that you can associate with a custom attribute for a searchable item. Item attributes provide metadata about the item that can be indexed and displayed to users in search results.

Although the Core Spotlight framework provides several predefined attributes, such as title and description, you can create a `CSCustomAttributeKey` object to specify a custom attribute that makes sense in your domain.

## Topics

### Creating a custom attribute

[`-  initWithKeyName:`](/documentation/CoreSpotlight/CSCustomAttributeKey/init(keyName:))

Returns a new custom attribute key with the specified name.

[`-  initWithKeyName:searchable:searchableByDefault:unique:multiValued:`](/documentation/CoreSpotlight/CSCustomAttributeKey/init(keyName:searchable:searchableByDefault:unique:multiValued:))

Returns a new custom attribute key with the specified name and properties.

[`init(coder:)`](/documentation/CoreSpotlight/CSCustomAttributeKey/init(coder:))

### Getting the attribute details

[`keyName`](/documentation/CoreSpotlight/CSCustomAttributeKey/keyName)

The name of the custom attribute key.

[`multiValued`](/documentation/CoreSpotlight/CSCustomAttributeKey/isMultiValued)

A Boolean value that indicates if the custom attribute is likely to have multiple values, such as arrays, associated with it.

[`searchable`](/documentation/CoreSpotlight/CSCustomAttributeKey/isSearchable)

A Boolean value that indicates if the custom attribute can be specified as a search term.

[`searchableByDefault`](/documentation/CoreSpotlight/CSCustomAttributeKey/isSearchableByDefault)

A Boolean value that indicates if the custom attribute should be searchable by default.

[`unique`](/documentation/CoreSpotlight/CSCustomAttributeKey/isUnique)

A Boolean value that indicates if duplicate custom attribute values should be treated as the same value to save storage space.

## Relationships

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)