【发布时间】:2022-01-25 12:36:07
【问题描述】:
我有一个 iOS 应用程序,它具有聚光灯搜索功能,允许用户从应用程序中搜索项目。它在 iOS 应用上运行良好
我正在将应用程序迁移为催化剂应用程序,不知何故,mac 催化剂应用程序上的聚光灯搜索不起作用
到目前为止,已经检查了以下内容
- Spotlight 搜索逻辑按预期工作,没有错误
- 重新启动的 Mac
- 多次打开 Catalyst 应用,检查它是否与核心 Spotlight 同步。
- 以前没有在 stack-overflow 上注册过问题
环境:macOS 12.0.1
P.S:我不确定它是否与我的代码相关,因为它在 iPad 和 iPhone 设备上运行良好。
let attributeSet = CSSearchableItemAttributeSet(contentType: .content)
attributeSet.title = decodeItem.name
attributeSet.relatedUniqueIdentifier = decodeItem.id
attributeSet.url = URL.init(string: decodeItem.url)
let searchableItem = CSSearchableItem(uniqueIdentifier: decodeItem.id,
domainIdentifier: "com.xxx.xxxx",
attributeSet: attributeSet)
searchableItems.append(searchableItem)
CSSearchableIndex.default().indexSearchableItems(searchableItems) { error in
if let error = error {
print("Issue indexing: \(error)")
} else {
print("Indexed.")
}
}
【问题讨论】:
标签: ios macos mac-catalyst spotlight corespotlight