Skip to content

Commit 55df13c

Browse files
committed
Update readme
1 parent cb5eb3c commit 55df13c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,21 @@ See [Alert.swift](https://github.com/AntonPoltoratskyi/NativeUI/blob/master/Nati
106106
When you need to present few alerts in a row you should set `shouldDismissAutomatically` flag to `false` and add action AFTER view controller initialization to be able to capture alert instance in action handler's closure.
107107

108108
```swift
109-
let cancelAction = Alert.Action(title: "Cancel", style: .primary)
110109

111110
let viewModel = Alert(
112111
title: "Your Title",
113-
message: "Your Message",
114-
actions: [cancelAction]
112+
message: "Your Message"
115113
)
116114
let alert = AlertViewController(viewModel: viewModel)
117115
alert.shouldDismissAutomatically = false
118116

117+
let cancelAction = Alert.Action(title: "Cancel", style: .primary) { [weak alert] _ in
118+
alert?.dismiss(animated: true) {
119+
// present something else
120+
}
121+
}
122+
alert.addAction(cancelAction)
123+
119124
let confirmAction = Alert.Action(title: "Confirm", style: .default) { [weak alert] _ in
120125
alert?.dismiss(animated: true) {
121126
// present something else

0 commit comments

Comments
 (0)