Indexing with CSSearchableItem

Currently, our indexing works and we can find any content we saw before. We can even select results from the Spotlight index and have our app open on the correct page. If you've taken on the challenge of implementing the handling of detail pages, your app should be able to handle continuation of any activity that has been indexed. Wouldn't it be cool if we could be a bit more proactive about indexing though? Ideally, we would index any new Family Members or movies as soon as the user adds them.

This is exactly what CSSearchableItem is good at. The CSSearchableItem class enables you to index content the user might not have seen before. Indexing CSSearchableItem instances is pretty straightforward. The steps involved are similar to how we indexed user activities. To index a searchable item, we will create an instance of CSSearchableItem and provide it with collection attributes that describe the item we will index. These attributes are encapsulated in an instance of CSSearchableItemAttributeSet.