我正在使用 UUID 来使用 DiffableDataSource,但我正在使用一个具有每个对象副本的数据集。
这是我在操场上使用的代码示例:
var movies: [MovieSearch] = []
struct MovieSearch: Hashable, Decodable, Equatable {
let uuid = UUID()
private enum CodingKeys : String, CodingKey { case Name, StartDate }
let Name: String
let StartDate: String
}
movies = [
MovieSearch(Name: "Blade Runner", StartDate: "01/01/2021"),
MovieSearch(Name: "Blade Runner: 2049", StartDate: "01/07/2021"),
MovieSearch(Name: "UBIK", StartDate: "01/14/2021"),
MovieSearch(Name: "Blade Runner", StartDate: "01/01/2021"),
MovieSearch(Name: "Blade Runner: 2049", StartDate: "01/07/2021"),
MovieSearch(Name: "UBIK", StartDate: "01/14/2021")
]
由于 UUID 是在初始化时添加的,在这种情况下是否有合理的方法来删除重复项?