I’ve just finished the 2nd chapter of the book and decided to modify behavior a bit: when a user hit the alert’s ok button to reset the game.
As far as I understand, for this, I need to mark xTarget variables with @State, also I’ve created a reset function where I reassign new values. Then I use Alert(title:message:primaryButton:) init method and in Button’s action I try to call this reset method but get an error message “Cannot use mutating member on immutable value”.
For anyone reading this now, the above code did not work for me. I found the code below on Stack Overflow, which did work, using something called an Alert.Button
thanks Steve! yes, .presentation changed to .alert(isPresented:) after I wrote that version. There’s a BullsEye version in the starter project for Chapter 5 that uses .alert(isPresented:).