title: Array of structs: UserDefaults, how to use?
body: <p>I've already check all of those topics:</p>
  
  <p><a href="https://stackoverflow.com/questions/38406457/how-to-save-an-array-of-custom-struct-to-nsuserdefault-with-swift/41296754#41296754">How to save an array of custom struct to NSUserDefault with swift?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/32674302/how-to-save-struct-to-nsuserdefaults-in-swift-2-0">How to save struct to NSUserDefaults in Swift 2.0</a></p>
  
  <p><a href="https://stackoverflow.com/questions/42777752/struct-array-to-userdefaults">STRUCT Array To UserDefaults</a></p>
  
  <blockquote>
    <p>I have a struct containing some Strings and an other struct: MySection. </p>
  </blockquote>
  
  <pre><code>struct MySection {
    var name: String = ""
    var values: [MyRow] = []
  }
  </code></pre>
  
  <blockquote>
    <p>And there is MyRow which is store in MySection.values</p>
  </blockquote>
  
  <pre><code>struct MyRow {
    var value: String = ""
    var quantity: String = ""
    var quantityType: String = ""
    var done: String = ""
  }
  </code></pre>
  
  <blockquote>
    <p>Two arrays for use it</p>
  </blockquote>
  
  <pre><code>var arraySection: [MySection] = []
  var arrayRow: [MyRow] = []
  </code></pre>
  
  <p>And in my application, I add dynamically some values in those arrays.</p>
  
  <blockquote>
    <p>There is the delegate method for get datas from my second ViewController</p>
  </blockquote>
  
  <pre><code>func returnInfos(newItem: [MyRow], sectionPick: String) {
      arrayRow.append(MyRow())
      arrayRow[arrayRow.count - 1] = newItem[0]
      manageSection(item: sectionPick)
      listTableView.reloadData()
  }
  </code></pre>
  
  <blockquote>
    <p>And there is the manageSection function.</p>
  </blockquote>
  
  <pre><code>func manageSection(item: String) {
      var i = 0
      for _ in arraySection {
          if arraySection[i].name == item {
              arraySection.insert(MySection(), at: i + 1)
              arraySection[i + 1].values = [arrayRow[arrayRow.count - 1]]
              return
          }
          i += 1
      }
      arraySection.append(MySection())
      arraySection[arraySection.count - 1].name = item
      arraySection[arraySection.count - 1].values = [arrayRow[arrayRow.count - 1]]
  }
  </code></pre>
  
  <p>My need is to store datas of the two arrays in UserDefaults (or CoreData maybe??) and use these datas when the user going back to the application.</p>
  
  <p>I don't know how to do it, I've already try methods from the 3 topics but I'm not even doing a good job. </p>
  
  <p>How can I do it?</p>
  
  <p>Thanks guys!</p>