CoreSpotlight indexing not working
I am using Apache CoreSpotLight to index some content. For some reason, I can't find the data when I search in Spotlight.
let atset:CSSearchableItemAttributeSet = CSSearchableItemAttributeSet()
atset.title = "Simple title"
atset.contentDescription = "Simple twitter search"
let item = CSSearchableItem(uniqueIdentifier: "id1", domainIdentifier: "com.shrikar.twitter.search", attributeSet: atset)
CSSearchableIndex.defaultSearchableIndex().indexSearchableItems([item]) { (error) -> Void in
print("Indexed")
}
When I run the application, I see that the data is indexed and the error is zero. I also added CoreSpotLight and MobileCoreServices to the build phase.
+3
source to share
1 answer
Try using your initializer itemContentType
like this:
let atset:CSSearchableItemAttributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeImage as String)
atset.title = "Simple title"
atset.contentDescription = "Simple twitter search"
let item = CSSearchableItem(uniqueIdentifier: "id1", domainIdentifier: "com.shrikar.twitter.search", attributeSet: atset)
CSSearchableIndex.defaultSearchableIndex().indexSearchableItems([item]) { (error) -> Void in
print("Indexed")
}
kUTTypeImage
announced in MobileCoreServices
.
+6
source to share