Changing Object's Properties Inside For Loop in Swift

后端 未结 2 1924
无人共我
无人共我 2021-02-20 18:17

I created a simple struct called ShoppingList.

struct ShoppingList {

    var shoppingListId :NSNumber
    var title :String
    var groceryItems :[GroceryItem]         


        
2条回答
  •  臣服心动
    2021-02-20 19:15

    Alright, I figured this out. It seems that the way you do this now is by making a reference and changing its properties inside of the loop (which does not change an original instance in case of structures). What you should do instead is call them directly like this:

    for index in 0..

    This works, I checked, you're welcome!

提交回复
热议问题