CSIndexErrorDomain 错误 -1005

CSIndexErrorDomain error -1005

我收到此错误 "The operation couldn’t be completed. (CSIndexErrorDomain error -1005.)" 而 运行 代码用于 ipad.Does 上的 Spotlight 搜索 有人知道如何解决此错误吗?

CoreSpotlight 在 iOS 9 之后可用。

虽然您的设备可能在 iOS 9.x,但如果它是旧设备版本,它仍然可能无法工作。

来自 Apple 文档。

Although app search is available for iOS 9 users, the search functionality of NSUserActivity and Core Spotlight is not supported on iPhone 4s, iPad 2, iPad (3rd generation), iPad mini, and iPod touch (5th generation)."

因此,如果您在上述任何设备或模拟器上进行相同的测试,您将收到 CSIndexErrorDomain 错误 -1005。

来自 Corespotlight API 文档

CSIndexErrorCodeIndexingUnsupported = -1005, //Indexing isn't supported on this device

由于并非所有支持 iOS9 的设备都支持搜索功能,因此请检查以下条件以了解设备是否支持搜索

if ([CSSearchableIndex isIndexingAvailable])

并保留此条件下的搜索方法。