|
I wanted to add the counter on how many times the activity was completed. But the button I created in ActivityView does not work because of the error "cannot use mutating member on immutable value: self is immutable" Why is my Activity immutable? How should I increment the counter? Activity
Activities
ActivityView
ContentView
|
|
You are trying to mutate the Here is a brief note from Paul. Normally with an @State the declaration would be
However, since you are calling the
|
|
Hi, thanks for the pointer. The Button woks now, of course the state is not preserved after I leave the detail view. Now I feel like I have to move away from passing a struct to the detail view, since I want to change it and preserve the change. So instead of
I shall find out the index of the item the user touches (to go to the Thank you for participating in my thinking process |
SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.