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 - 如何在 swift UI 测试中根据标签值查找标签中的静态文本?

ios - Expo v33 托管应用程序 - Facebook 和 Google 登录无法在已部署的 iOS 上运行

ios - 如何在 iOS 10 通知中获取应用程序状态?

MySQL 查询的细化

video - 从 SWF 文件中提取视频

iphone - 在 MPMoviePlayerController 中播放全屏 .mp4 视频?

java - 如何在Java中进行.MOV到3GP的转换操作

ios - fetchedResultsController 不更新过滤器

algorithm - 统一成本搜索的时间复杂度

java - 查找字符串的超字符串的最快数据结构?