Reputation: 1964
How to decide which one is most suitable among CoreSpotlight framework & NSUserActivity for Search Programming.
Upvotes: 5
Views: 1044
Reputation: 48215
In addition to @sash 's answer, you may want to watch WWDC 2015 Session 709 Introducing App Search
The same
userActivity
in application(_:continueUserActivity:restorationHandler:)
has activityType == CSSearchableItemActionType
CSSearchableItemAttributeSet
to describe attributeThe differences
CoreSpotlight
CSSearchableItem.attributeSet
CoreSpotlight is for private data which is indexed on the device and you can use CoreSpotlight to comprehensively index data in your app.
If you're building or you have a social networking app for instance and you wanted to index all of the messages that the user has sent and received, CoreSpotlight is the right tool for the job.
NSUserActivity
contentAttributes
eligibleForPublicIndexing
Use NSUserActivity for both public and private content as well as for indexing navigation points inside of your app.
Now there is another flavor of NSUserActivity that Dave touched on which is Public Indexing.
More about NSUserActivity
becomeCurrent
is for Handoff to start the broadcasting processeligibleForHandoff = false
and eligibleForSearch = true
to get the nearly same effect as CoreSpotlight
NSUserActivity
objects around until the index work finishesDesigned to work together
These APIs while distinct, they're really designed to work together.
In the same app for the same content you can adopt multiple APIs.
The only thing to remember is for items that are indexed from multiple places, you want to connect these items by giving them the same ID.
More resources
Upvotes: 4
Reputation: 8747
CoreSpotlight
NSUserActivity
Upvotes: 4