title: deep copy for array of objects in swift
body: <p>I have this class named Meal</p>
  
  <pre><code>class Meal {
      var name : String = ""
      var cnt : Int = 0
      var price : String = ""
      var img : String = ""
      var id : String = ""
  
      init(name:String , cnt : Int, price : String, img : String, id : String) {
          self.name = name
          self.cnt = cnt
          self.price = price
          self.img = img
          self.id = id
      }
  }
  </code></pre>
  
  <p>and I have an array of Meal :</p>
  
  <pre><code>var ordered = [Meal]()
  </code></pre>
  
  <p>I want to duplicate that array and then do some changes to the Meal instances in one of them without changing the Meal instances in the second one, how would I make a deep copy of it?</p>
  
  <p>This search result didn't help me 
  <a href="https://stackoverflow.com/questions/27812433/swift-how-do-i-make-a-exact-duplicate-copy-of-an-array">How do I make a exact duplicate copy of an array?</a></p>