Swift 2.0 Core Spotlight API - search only for title

711 views Asked by At

I'am testing the new Core Sportlight API feature in iOS 9. The indexing process works well but is there a way to define that the indexed Item should only get searched by the "title" Attribute instead of "title" and "description"?

Maybe you already have some more informations than me.

1

There are 1 answers

6
Tejas HS On

I have tried doing this using Objective C, and it works perfectly.

It depends on what implementation of "CSSearchableAttributeSet" is used. In obj C, there are many implementations of CSSearchableAttributeSet like

  1. CSSearchableItemAttributeSet_General
  2. CSSearchableItemAttributeSet_Document
  3. CSSearchableItemAttributeSet_Image and others.

I have used CSSearchableItemAttributeSet_General in my code and I'm able to search by the title attribute only. In fact, that particular implementation of CSSearchableItemAttributeSet doesn't even have a "description" attribute.

So depending on what type of object you want to search for, you can use the particular implementation.

I believe it would be the same equivalent class in swift as well.

-Tejas