I am facing the above error while trying this:
protocol Style {}
struct StyleA: Style {}
struct StyleA: Style {}
struct StyleA: Style {}
struct Preset: Identifiable {
let id: UUID = UUID()
let title: String
let style: Style
}
extension View {
public func applyStyle<S>(_ style: S) where S : Style {
// USe the style here
}
}
// Initializg the data
static let mockedData: [Preset] = [
.init(title: "Title A", style: StyleA()),
.init(title: "Title A", style: StyleB()),
.init(title: "Title A", style: StyleC()),
]
// This line gives the error
myView.applyStyle(mockedData.first!.style)
How can I fix it? Shouldn't it resolve the concrete type?
Thanks for your help.