如何在CSSearchableItem中更改年份日期(内容类型 - kUTTypeMovie)?

问题描述 投票:3回答:1

我有一个带视频内容的应用程序,我使用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,还设置addedDate以及CSSearchableItemAttributeSet_Media.h提供的所有其他日期。但它始终是2018

ios search movie corespotlight nsuseractivity
1个回答
1
投票

我能够重现这一点。

然而,当我把这个CSSearchableItemAttributeSet不在NSUserActivity里面而是在CSSearchableItemCSSearchableIndex.default().indexSearchableItems()的索引里面时,搜索结果根据需要说1989

这对你有用吗?

© www.soinside.com 2019 - 2024. All rights reserved.