Skip to content

Instantly share code, notes, and snippets.

@MathVasc
Created February 9, 2018 19:55
Show Gist options
  • Save MathVasc/1d016f03e738bbb9d20637fc8d82e62e to your computer and use it in GitHub Desktop.
Save MathVasc/1d016f03e738bbb9d20637fc8d82e62e to your computer and use it in GitHub Desktop.
public static func setSpotLightIndexes(){
//.
//.
//.
for item in items {
//1
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String)
//2
attributeSet.keywords = ["Groceries", "Grocery", "List"]
attributeSet.title = item.name
attributeSet.contentDescription = item.isDone ? "\(item.name!) was bought" : "\(item.name!) wasn't bought"
//3
attributeSet.thumbnailData = item.isDone ? UIImagePNGRepresentation(UIImage(named: "Check")) : UIImagePNGRepresentation(UIImage(named:"Uncheck"))
//4
searchableItems.append(CSSearchableItem(uniqueIdentifier: item.name!, domainIdentifier: nil, attributeSet: attributeSet))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment