Save several items to core data

Hey, guys. I am trying to save the array "allShops" to the entity "CoffeeShop" which they both have the attributes "id","name","latitude","longitude". But every time I seems to get the last item of the array rather than the whole array. What's the reason for that?47

The Swift forums aren't really the place for Core Data discussion (and especially not the 'evolution' category), but this bug is quite simply solved so here you go:

You need to move the let newEntity = ... line inside the for loop, so it will create and insert a new entity for every shop.

Your current code is only ever creating one entity, updating it repeatedly with new values, and saving once — which means when it is saved it is set to the data of the last item in the array.

Moved and tagged. ;)

That works! Thanks!!