The on-device index.


@interface CSSearchableIndex : NSObject


The CSSearchableIndex class defines an object that represents the on-device index. In your app, you can designate user activities (that is, activities that can be represented by NSUserActivity) and app content as eligible for search. Using CSSearchableItem and CSSearchableItemAttributeSet APIs, you identify and provide information about activities and other items and then use CSSearchableIndex methods to manage the indexing of the items.

In some cases, it works well to batch updates to the index and save state information (up to 250 bytes) that helps you handle errors in the process. For example, you can use the client state information you pass in endIndexBatchWithClientState:completionHandler: to determine where indexing should resume in case of a crash or jetsam. (Note that state information is reset every time deleteAllSearchableItemsWithCompletionHandler: is called.) You can batch updates using indexSearchableItems:completionHandler: and deleteSearchableItemsWithIdentifiers:completionHandler:, but you can’t batch updates to the default index returned by defaultSearchableIndex.

In batch mode, the client takes responsibility for protecting the private CSSearchableIndex instance from concurrent access from multiple threads; concurrent calls to the index instance have undefined results. Although you can call beginIndexBatch again before the completion handler passed to endIndexBatchWithClientState:completionHandler: has been called, don’t call it before endIndexBatchWithClientState:completionHandler: has returned.


Determining Indexing Capability

+ isIndexingAvailable

Returns a Boolean value that indicates whether indexing is available on the current device.

Getting an Index

+ defaultSearchableIndex

Returns the default on-device index.

- initWithName:

Returns an on-device index with the specified name.

- initWithName:protectionClass:

Returns an on-device index with the specified name and data protection class.

Setting the Delegate


A protocol defining methods a delegate object or app extension uses to handle communication from the on-device index.


The delegate object that can handle index-management tasks.

Managing Items in an Index

- deleteAllSearchableItemsWithCompletionHandler:

Deletes all searchable items from the index.

- deleteSearchableItemsWithDomainIdentifiers:completionHandler:

Removes from the index all searchable items associated with the specified domain.

- deleteSearchableItemsWithIdentifiers:completionHandler:

Removes from the index all items with the specified identifiers.

- indexSearchableItems:completionHandler:

Adds or updates items in the index.

Batching Index Updates

- beginIndexBatch

Begins a batch of updates to an index.

- endIndexBatchWithClientState:completionHandler:

Ends a batch of index updates and stores the specified state information.

- fetchLastClientStateWithCompletionHandler:

Gets the app’s most recently stored state information.


Inherits From

See Also



An interface that implements an index-maintenance app extension.