Message Item Alert
Presents an alert with a message using the given data to produce the alert’s content and a localized string key for a title.
Platform Compatibility
Tags
SwiftUI Code
struct Item {
let message: String
}
@State var item: Item? = .init(message: "Foo")
var body: some View {
Text("Foo")
.alert("Title", item: $item) { alertItem in
Button("Ok") {
print("Item nilled")
}
} message: { alertItem in
Text(alertItem.message)
}
}