我有一个包含视频内容的应用程序,我使用 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
。
这对你有用吗?
关于ios - 如何更改 CSSearchableItem 中的年日期(内容类型 — kUTTypeMovie)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48954105/