iOS 9 brings with it some really exciting functionality, such as indexing contents inside your app as searchable content on an iOS device. Even better, you can contribute to iOS’s public search index so that your searchable content appears on devices that don’t even have your app installed. That’s pretty cool, don’t you agree? In this chapter we’ll have a look at all these great features.
You want the user to be able to search within the contents inside your app, from iOS’s search functionality (see Figure 6-1).
First construct an object of type
CSSearchableItemAttributeSet. This will represent the metadata for any one item that you want to index in the search. Having the metadata, construct an instance of the
CSSearchableItem class with your metadata and expiration date, plus some other properties that you will see soon. Index an item using the
CSSearchableIndex class. You’ll get a completion block that will let you know whether or not things went well.
You have to keep quite a few things in mind when indexing items in the local device search functionality. I’ll walk you through them one by one. Always keep this index in a useful state. Don’t index stuff that you don’t need, and make sure you delete the old items. You can specify ...