Saving an array of objects in UserDefaults
<p>Using swift 3.0, I'm trying to add an array of objects into user defaults. As this isn't one of the regular UserDefault types I've realised that the object or array of objects (can't work out which one) will need to be parsed to the type NSData to then be added to UserDefaults.</p>

<p>My attempt so far is the following:</p>

<p>Within the object</p>

<pre><code>func updateDefaults()
{
    let data = NSData(data: MyVariables.arrayList)
    UserDefaults.standard.set(data, forKey: "ArrayList")
}
</code></pre>

<p>Where MyVariables.arrayList is the array of objects.</p>

<p>Lastly, if possible it would be nice to know how to retrieve this from UserDefaults and convert it to the original one-dimensional array of objects.</p>

<p>Thanks</p>

<p>REPOSITORY: <a href="https://github.com/Clisbo/ModularProject" rel="nofollow noreferrer">https://github.com/Clisbo/ModularProject</a></p>