I'm trying to add Image?
on my data model in SwiftUI project for add this image into my array of data with the new PhotoPicker announced on WWDC22.
It returns me this error message:
Type 'RecipeModel' does not conform to protocol 'Hashable'
Stored property type 'Image?' does not conform to protocol 'Hashable', preventing synthesized conformance of 'RecipeModel' to 'Hashable'
struct RecipeModel: Identifiable, Equatable, Hashable {
static func ==(lhs: RecipeModel, rhs: RecipeModel) -> Bool {
return lhs.formImage == rhs.formImage
}
var id = UUID()
let image: String
var formImage: Image?
let name: String
let recipeType: RecipeType
let timeToCook: Int
let averagePrice: RecipeAveragePrice
let difficulty: RecipeDifficulty
let ingredients: [String]
let description: String
}
enum RecipeType: String, CaseIterable {
case entry = "Entrée"
case dish = "Plat"
case dessert = "Dessert"
}
enum RecipeAveragePrice: String {
case cheap = "Économique"
case medium = "Moyen"
case expensive = "Cher"
}
enum RecipeDifficulty: String {
case easy = "Facile"
case medium = "Moyenne"
case hard = "Difficile"
}