I am trying to create a test application that uses CoreSpotlight to provide content search in iOS Spotlight. Currently, I have a setting when the user enters the update button, then makes a server request, and then deleteAllSearchableItems, then indexSearchableItems(maybe not the best way, but the easiest way now, since I'm still at the initial stages of calculating this way out).
Below is my code that does this.
var searchableItems: [CSSearchableItem] = []
for i in 0 ..< self._ids.count {
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String)
attributeSet.title = self._titles[i]
attributeSet.contentDescription = self._descriptions[i]
let searchableItem = CSSearchableItem(uniqueIdentifier: self._ids[i], domainIdentifier: "com.domain.appname", attributeSet: attributeSet)
searchableItems.append(searchableItem)
}
CSSearchableIndex.default().deleteAllSearchableItems(completionHandler: { (error) -> Void in
CSSearchableIndex.default().indexSearchableItems(searchableItems) { (error) -> Void in
if error != nil {
print(error?.localizedDescription ?? "Error")
}
}
})
My next thing I'm trying to do is an array of images with a name self._images. Inside this array is either an empty string ( "") or a URL string ( "https://mywebsite.com/image.png").
, UIImageView URL-, AlamofireImage.
if (self._images[0] != "") {
myImageView.af_setImage(withURL: URL(string: self._images[0])!)
}
CoreSpotlight attributeSet?
, attributeSet.thumbnailData.af_setImage(withURL: imagedownloadURL) . , .
?
, , , async, , , , .
!