title: What is the best way to save and load an array of custom objects using swift?
body: <p>I have an app that saves locations that a user provides by pressing on a map. The custom class looks like this: </p>
  
  <pre><code>class Places {
  var name = ""
  var latitude : CLLocationDegrees
  var longitude : CLLocationDegrees
  
  init(name: String, latitude: CLLocationDegrees, longitude:CLLocationDegrees) {
  
  self.name = name
  self.latitude = latitude
  self.longitude = longitude
  }
  </code></pre>
  
  <p>Then outside of the first viewController, a TableView, I set an empty array of these custom objects.</p>
  
  <pre><code>var places = [Places]()
  </code></pre>
  
  <p>On the next view controller, these objects are created after a long press on map. </p>
  
  <pre><code>var newPlace = Places(name: title, latitude: newCoordinate.latitude, longitude: newCoordinate.longitude)
  
              places.append(newPlace)
  </code></pre>
  
  <p>The app works well but nothing gets saved when it is closed. I tried saving the array to <code>NSUserDefaults</code> but apparently that can't be done with custom object arrays. What would be the most efficient way to save this array and then load it?</p>