Is there an example code for corespotlight search feature - iOS 9 API?

mojo_ picture mojo_ · Jun 26, 2015 · Viewed 14.9k times · Source

Is there an example code for corespotlight search feature - iOS 9 API? Really appreciate if can look at sample code to implement/test.

Answer

mayqiyue picture mayqiyue · Jul 10, 2015
  1. Create a new iOS project and add CoreSpotlight and MobileCoreServices framework to your project. enter image description here

  2. Create the actual CSSearchableItem and associating the uniqueIdentifier, domainIdentifier and the attributeSet. Finally index the CSSearchableItem using [[CSSearchableIndex defaultSearchableIndex]...] as show below. enter image description here

  3. OK!Test the index!
    enter image description here