---
title: "init(keyName:)"
framework: corespotlight
role: symbol
role_heading: Initializer
path: "corespotlight/cscustomattributekey/init(keyname:)"
---

# init(keyName:)

Returns a new custom attribute key with the specified name.

## Declaration

```swift
convenience init?(keyName: String)
```

## Parameters

- `keyName`: The name of the custom attribute for use as a key in a doc://com.apple.corespotlight/documentation/CoreSpotlight/CSSearchableItemAttributeSet. The key name must be a string that contains only ASCII characters and no punctuation other than the underscore (that is “_”). The prefix kMD is reserved.

## Return Value

Return Value A new custom attribute key.

## Discussion

Discussion To create custom attribute key names, use a reverse DNS format that includes your company name and does not include the period character (”.”). For example, a key name of the form com_mycompany_myapp_mykeyname works well.

## See Also

### Creating a custom attribute

- [init(keyName:searchable:searchableByDefault:unique:multiValued:)](corespotlight/cscustomattributekey/init(keyname:searchable:searchablebydefault:unique:multivalued:).md)
- [init(coder:)](corespotlight/cscustomattributekey/init(coder:).md)
