I have a searchController, when I try to delete the text in searchController it crash the message is.
supplied identifiers are not unique
I try to fix it with hasher function like this and make my model Hashable, and Equatable. but still not fix the problem, please help. this is my code, if there is something not clear in my code. feel free to mention me I will update it :)
struct PhotosResults: Decodable {
var total, totalPages: Int
var results: [PhotoItem]
}
// MARK: - Result
struct PhotoItem: Decodable {
var id: String
var createdAt: String
var width, height: Int
var color: String
var likes: Int
var likedByUser: Bool
var description: String?
var user: User
var urls: Urls
}
extension PhotoItem: Hashable, Equatable {
static func == (lhs: PhotoItem, rhs: PhotoItem) -> Bool {
return lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
// MARK: - Urls
struct Urls: Decodable {
var raw, full, regular, small: String
var thumb: String
}
// MARK: - User
struct User: Decodable {
var id, username, name, firstName: String
var lastName, instagramUsername, twitterUsername: String?
var portfolioUrl: String?
var profileImage: ProfileImage
}
extension User: Hashable, Equatable {
static func == (lhs: User, rhs: User) -> Bool {
return lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
// MARK: - ProfileImage
struct ProfileImage: Decodable {
var small, medium, large: String
}