I am using a UUID to get the use of DiffableDataSource but I am working with a data set that has a duplicate of every object.
Here is a sample of the code I am working with from a playground:
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")
]
Since the UUID is added at the time of initialization is there a reasonable way to delete the duplicates in this scenario?