Implementing user feedback with alerts
The user can get a random word and try and make some words out of that word in the language of their choice, but there are certain checks that we’ve put in place that will stop those words from entering the list. Now, we need to let the user know why a certain word is not acceptable, using SwiftUI alerts.
Let’s go back into DataModel
and fill out the displayErrorMessage
function stub with the appropriate code to get a message alert. Add the following code right into the method:
//error message func displayErrorMessage(messageTitle: String, description: String) { errorTitle = messageTitle errorDescription = description errorMessageIsShown = true }
The code takes the messageTitle
string and assigns...