title: Converting custom class object into NSData
body: <p>I have a custom class that I want to save into <code>NSUserDefaults</code>. I am told that I need to convert the class object into data in order to save it to <code>NSUserDefaults</code>. I found a lot of discrete string or ints to <code>NSData</code> examples but nothing on custom class to <code>NSData</code>. I know very little about the intricacies of <code>NSData</code> encoding etc. Any help is appreciated</p>
  
  <p>EDIT: While I understand there are similar answers here, none of them are in Swift. Translating between the languages is doable, but it is extremely tedious and sometimes very counter-intuitive.</p>