id/UUID() Unable To Be Assigned

Hi! Thank you for reading this. I was trying to refresh my skills on using Lists and creating a very basic app with the name of my school teachers as a list. So the first step I did was create a model, and then realized I needed to assign an ID to each of the values in my array. Although, when I tried to assign an id, it told me “Cannot assign to property: r is a let constant” (with r being the value I used in my for-in loop).

I attached a screenshot below, any help is greatly appreciated! Thank you, have a nice day :slight_smile: !

Instead in your model you can already assign it rather than in a for loop later

var id= UUID()

Put that in the model, rather than var id: UUID?

But also in your code lines 36-39 you’ve already assigning a UUID and using a for loop isn’t necessary to reassign

1 Like

Oh I see! Alright, thank you! :slight_smile: