[英]Spotlight search not working for mac catalyst apps
I've an iOS app that has spotlight search feature which allows user to search items from an app.我有一个 iOS 应用程序,它具有聚光灯搜索功能,允许用户从应用程序中搜索项目。 It works fine on iOS app
它在 iOS 应用程序上运行良好
I am in the process of migrating the app as a catalyst app, somehow the spotlight search on mac catalyst app is not working我正在将应用程序迁移为催化剂应用程序,不知何故,mac 催化剂应用程序上的聚光灯搜索不起作用
So far following things have been checked到目前为止,已经检查了以下内容
Env: macOS 12.0.1环境:macOS 12.0.1
PS: I am unsure if it is related to specific to my code as it is working fine on iPad and iPhone devices. PS:我不确定它是否与我的代码相关,因为它在 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.")
}
}
Found the issue: Assign value to attributeSet.relatedUniqueIdentifier only from initializer发现问题: 仅从初始化程序将值分配给attributeSet.relatedUniqueIdentifier
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.