Contents

CSSearchableItem

The details of your app-specific content that someone might search for on their devices.

Declaration

class CSSearchableItem

Mentioned in

Overview

A CSSearchableItem uniquely identifies a part of your app’s content, and provides the metadata that Spotlight indexes and uses to find that content later. As part of indexing your app’s content, you create searchable items and fill them with details about your app’s content and where to find it. After indexing the content, you can then execute queries using the Core Spotlight APIs to find the items you indexed. People can also use the system’s Spotlight search interface to find your app’s content.

When you create or update content in your app, create a CSSearchableItem for that content if you want it to be searchable. A searchable item contains identification strings you use to locate that item in your content and a CSSearchableItemAttributeSet object with details about the item. For the metadata, you typically want to provide values for the title, displayName, and contentType attributes at a minimum. If you’re indexing a file on disk, provide a value for the contentURL attribute. Fill in as many other attributes as makes sense for the content you’re indexing.

After creating a searchable item, index it using a CSSearchableIndex object. As you update your app’s content, update your CSSearchableItem objects for that content and index them right away. If you delete content, similarly delete the searchable items from the index. Keeping your app’s indexes current ensures that searches return valid information. For more information on indexing your content, see Adding your app’s content to Spotlight indexes.

Topics

Getting a searchable item

Setting attributes on a searchable item

Continuing a search or activity

Comparing items

Deprecated

Initializers

See Also

Searchable items