title: How to save array of objects (with image variables) in Swift and Xcode?
body: <p>I am wondering how to save an array of objects from the following class:</p>
  
  <pre><code>class CustomDocument: NSObject, NSCoding {
      let name : String
      let image : UIImage
  
      init(n: String, i: UIImage){
          name = n
          image = i
      }
  
      //other code excluded
  }
  </code></pre>
  
  <p>Originally, I saved this array to User Defaults. Because the objects took up a lot of space, it caused a lot of lag in the app. </p>
  
  <p>What is the best way to save an array of data that takes up a lot of space? </p>
  
  <p>Thank you so much for the help and all responses are appreciated.</p>