SearchApi功能中NSUserActivity的任何示例代码?

时间:2015-08-13 10:44:57

标签: objective-c xcode7 ios9 itunes-search-api ios-9-beta3

任何人都可以在SearchApi的NSUserActivity功能中为我提供教程或示例代码。我正在做很多关于此功能的RND,但没有得到适当的代码。

1 个答案:

答案 0 :(得分:2)

一个例子是:

let activity = NSUserActivity(activityType: "com.tutsplus.iOS-9-Search.displayShow")
activity.userInfo = ["name": detailItem.name, "genre": detailItem.genre, "time": detailItem.time]
activity.title = detailItem.name
var keywords = detailItem.name.componentsSeparatedByString(" ")
keywords.append(detailItem.genre)
activity.keywords = Set(keywords)
activity.eligibleForHandoff = false
activity.eligibleForSearch = true
//activity.eligibleForPublicIndexing = true
//activity.expirationDate = NSDate()

activity.becomeCurrent()

有关更多信息和示例,请参阅this link