我有一个带视频内容的应用程序,我使用NSUserActivity
跟踪所有查看的项目,将其添加到Spotlight。结果看起来很完美,除了年份日期,总是将NSUserActivity
添加到索引中的一年。但是我需要改变它来发布电影的一年。
let activity = NSUserActivity(activityType: "com.bundleid.movie")
activity.isEligibleForSearch = true
activity.title = "Mess"
let movie = kUTTypeMovie as String
let attributes = CSSearchableItemAttributeSet(itemContentType: movie)
attributes.title = "Mess"
attributes.contentDescription = "Even if you get behind bars..."
attributes.thumbnailData = try? Data(contentsOf: thumbURL) // cover
attributes.rating = NSNumber(value: 3.7)
attributes.ratingDescription = "(Kinopoisk: 7.9, IMDb: 7.4)"
attributes.duration = NSNumber(value: 5785) // 1:36:25 in sec
attributes.contentCreationDate = dateFormatter.date(from: "1989") // ¯\_(ツ)_/¯
activity.contentAttributeSet = attributes
我正在尝试不仅设置attributes.contentCreationDate
,还设置addedDate
以及CSSearchableItemAttributeSet_Media.h
提供的所有其他日期。但它始终是2018
(
我能够重现这一点。
然而,当我把这个CSSearchableItemAttributeSet
不在NSUserActivity
里面而是在CSSearchableItem
和CSSearchableIndex.default().indexSearchableItems()
的索引里面时,搜索结果根据需要说1989
。
这对你有用吗?