使用NSUserActivity&之间的基本区别是什么?用于搜索编程的CoreSpotlight框架?如何选择呢? [英] What is the basic difference between using NSUserActivity & CoreSpotlight framework for Search programming? How to choose among them?

查看:124
本文介绍了使用NSUserActivity&之间的基本区别是什么?用于搜索编程的CoreSpotlight框架?如何选择呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定CoreSpotlight框架和放大器中最适合哪一个? NSUserActivity用于搜索编程.

How to decide which one is most suitable among CoreSpotlight framework & NSUserActivity for Search Programming.

推荐答案

除了@sash的答案外,您可能还想观看

In addition to @sash 's answer, you may want to watch WWDC 2015 Session 709 Introducing App Search

相同

    application(_:continueUserActivity:restorationHandler:)中的
  • userActivity具有activityType == CSSearchableItemActionType
  • 使用CSSearchableItemAttributeSet来描述属性
  • userActivity in application(_:continueUserActivity:restorationHandler:) has activityType == CSSearchableItemActionType
  • Utilize CSSearchableItemAttributeSet to describe attribute

差异

CoreSpotlight

CoreSpotlight

  • 打算为许多项目建立索引,使其可搜索
  • 使用CSSearchableItem.attributeSet
  • 描述属性
  • 划船
  • 更新,删除
  • Intend for indexing many items, making them searchable
  • Describe attribute with CSSearchableItem.attributeSet
  • batching
  • update, deleting

CoreSpotlight用于在设备上建立索引的私人数据,您可以使用CoreSpotlight全面索引应用程序中的数据.

CoreSpotlight is for private data which is indexed on the device and you can use CoreSpotlight to comprehensively index data in your app.

例如,如果您正在构建或有一个社交应用程序,并且想要索引用户已发送和接收的所有消息,则CoreSpotlight是执行此任务的正确工具.

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

NSUserActivity

  • 用于索引当前活动的意图,以便在Spotlight中方便使用,以便我们接听
  • 使用contentAttributes
  • 描述属性
  • 允许内容在eligibleForPublicIndexing
  • 中公开发布在Apple Cloud中
  • Intent for indexing current activity, making it convenient in Spotlight so that we can pick up
  • Describe attribute with contentAttributes
  • Allow content to be in Apple cloud public in eligibleForPublicIndexing

将NSUserActivity用于公共和私人内容,以及为应用程序内部的导航点编制索引.

Use NSUserActivity for both public and private content as well as for indexing navigation points inside of your app.

现在,Dave谈到了NSUserActivity的另一种形式,即Public Indexing.

Now there is another flavor of NSUserActivity that Dave touched on which is Public Indexing.

有关NSUserActivity

More about NSUserActivity

  • becomeCurrent用于Handoff开始广播过程
  • 我们可能使用eligibleForHandoff = falseeligibleForSearch = true来获得与CoreSpotlight几乎相同的效果
  • 在索引工作完成之前,我们必须保留NSUserActivity个对象
  • 我们不知道索引工作何时完成
  • becomeCurrent is for Handoff to start the broadcasting process
  • We may use eligibleForHandoff = false and eligibleForSearch = true to get the nearly same effect as CoreSpotlight
  • We must keep NSUserActivity objects around until the index work finishes
  • We don't know when the index work finishes

旨在协同工作

这些API尽管截然不同,但它们实际上是设计为可以协同工作的.

These APIs while distinct, they're really designed to work together.

在同一个应用中,对于相同的内容,您可以采用多个API.

In the same app for the same content you can adopt multiple APIs.

唯一要记住的是,对于从多个位置建立索引的项目,您要通过为它们提供相同的ID来进行连接.

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.

更多资源

  • App Search Programming
  • Integrating with iOS System Search

这篇关于使用NSUserActivity&之间的基本区别是什么?用于搜索编程的CoreSpotlight框架?如何选择呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆