I'm looking to show an Alert without needing to press a button, i.e. programmatically. In Swift 5 / SwiftUI in 2022.
Searching has shown me this
let alert = UIAlertController(title: "alert", message: "message", preferredStyle: UIAlertController.Style.alert)
self.present(alert, animated: true, completion: nil)
When trying the above code it has issue with the nil in the completion block, but when changing it to curlys it says the view file doesn't have present
. Looks to not be for SwiftUI.
How can I show an Alert in Swift 5/SwiftUI without needing a button press?