Skip to content

Commit

Permalink
chore: fix spotlight indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
x86y committed Oct 17, 2023
1 parent 1a6dcfe commit 74aced3
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions Beacon/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ struct ContentView: View {
let output = UserDefaults.standard.integer(forKey: "lang") == Language.bqn.rawValue
? e(input: input)
: ke(input: input)
let attributeSet = CSSearchableItemAttributeSet(contentType: .plainText)
attributeSet.title = input
attributeSet.contentDescription = output
let uniqueIdentifier = UUID().uuidString
let searchableItem = CSSearchableItem(uniqueIdentifier: uniqueIdentifier, domainIdentifier: "arrscience.Beacons", attributeSet: attributeSet)
CSSearchableIndex.default().indexSearchableItems([searchableItem]) { error in
if let error = error {
print("Indexing error: \(error.localizedDescription)")
} else {
print("Search item successfully indexed!")
}
}

let attr = CSSearchableItemAttributeSet(contentType: .item)
attr.title = input
attr.contentDescription = output
attr.displayName = input
let uid = UUID().uuidString
let item = CSSearchableItem(uniqueIdentifier: uid, domainIdentifier: "arrscience.beacons", attributeSet: attr)
CSSearchableIndex.default().indexSearchableItems([item])

viewModel.addMessage(with: input, out: output, lang: lang, for: curBuffer)
} else {
isFocused = false
Expand Down

0 comments on commit 74aced3

Please sign in to comment.