Reputation: 759
I have this script:
List {
//code
}.presenation($displayAlert) {
Alert(title: Text("Start1"), message: Text("other...."), dismissButton: .default(Text("Go!")))
}
I receive error:
"Protocol type 'Any' cannot conform to 'View' because only concrete types can conform to protocols"
I think that the .presentation is deprecate on Version 11.0 (11A420a)
How can I fix this error?
Thank you!
Upvotes: 0
Views: 72
Reputation: 28539
To show an alert you need to use the .alert
modifier as the .presentation
modifier was deprecated in Beta 4.
Here is a quick example showing how to use it.
struct ContentView: View {
@State var showAlert = false
var body: some View {
List {
Button(action: {
self.showAlert.toggle()
}) {
Text("press me")
}
}.alert(isPresented: $showAlert) {
Alert(title: Text("Title"), message: Text("Message"), dismissButton: .default(Text("OK!")))
}
}
}
You may also want to consider updating your version of Xcode as 11.2 was released today
Upvotes: 1