ios - 如何更改 CSSearchableItem 中的年日期(内容类型 — kUTTypeMovie)?

标签 ios search movie corespotlight nsuseractivity

我有一个包含视频内容的应用程序,我使用 NSUserActivity 跟踪所有查看的项目以将其添加到 Spotlight。结果看起来很完美,除了年份,它始终是 NSUserActivity 被添加到索引的年份。但我需要将其更改为电影的发行年份。

Movie item representation in Spotlight

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,还尝试设置 addedDateCSSearchableItemAttributeSet_Media.h 中可用的所有其他日期。但始终是 2018(

最佳答案

我能够重现这个。

但是,当我将此 CSSearchableItemAttributeSet 放在 NSUserActivity 内,而是放在 CSSearchableItem 内并使用 CSSearchableIndex 对其进行索引时。 default().indexSearchableItems(),搜索结果显示为1989

这对你有用吗?

关于ios - 如何更改 CSSearchableItem 中的年日期(内容类型 — kUTTypeMovie)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48954105/

相关文章:

ios - Main.Storyboard 框架未更新

php - 获取数组中子串出现的次数

Mysql搜索查询两列

mysql IN() 和 LIKE 在一起

javascript - 使用 javascript 控制 .mov (<object>) 文件?

iphone - 如何在给定时间暂停电影?IOS

ios - 如何在 iOs 上获取 Twitter access token 和 secret?

ios - Facebook SDK for IOS、Swift - 使用多个目标、不同的包标识符等

ios - 如何解决 UITableViewController 的指定初始化错误?

python - 尝试在 Python 中使用 matplotlib 保存图形动画 - "Invalid file object: <_io.BufferedReader name=76>"