8
votes

I'm facing an error says "cannot assign to property" as seen in the preview image.

I get this error when I use the variable inside the struct of View and inside the forEach.

Here's Screenshot.enter image description here

1

1 Answers

17
votes

Define you currentMood as a @State variable:

@State var currentMood: String

You'll likely need to assign it with self.currentMood = moodData (adding self.)