Active Filters: Core Spotlight

Topics

#23: Core Spotlight 🔍

Topics

Core Spotlight allows your content to appear in the results of system-level Spotlight searches.

let attrSet = CSSearchableItemAttributeSet(
  itemContentType: kUTTypeText as String
)

attrSet.title = "#23: CoreSpotlight"
attrSet.contentDescription = "CoreSpotlight allows your content to appear in the results of system-level Spotlight searches."

let item = CSSearchableItem(
  uniqueIdentifier: "023",
  domainIdentifier: "com.lilbitesofcocoa.bites",
  attributeSet: attrSet
)

CSSearchableIndex
  .defaultSearchableIndex()
  .indexSearchableItems([item]) { error in
    print("Success!")
  }

Of course Core Spotlight is just one of many ways to get your content into search results, be sure to also look into the NSUserActivity APIs as well as Apple's Web markup guides.