title: Can `AnyObject` in Swift handle any type of objects? Really?
body: <p><strong>I'm asking this question to know what <code>AnyObject</code> means. I've resolved my error though.</strong> </p>
  
  <p>I've a class using to store some user values, lets say</p>
  
  <pre><code>class UserDetails : NSObject
  {
      var name : String?
  
      init(name : String)
      {
          super.init()
          self.name = name
      }
  }
  </code></pre>
  
  <p>and I'm storing a object of class <code>UserDetails</code> to <code>NSUserDefaults</code> as</p>
  
  <pre><code>NSUserDefaults.standardUserDefaults().setObject(userData, forKey: "user_details")
  </code></pre>
  
  <p>the above line not displaying any error to me as methods <code>setObject</code> takes argument of type <code>AnyObject?</code> but at the time of execution its displaying the error</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
  reason: 'Attempt to insert non-property list object &lt;Sample.UserDetails: 0x7b1189b0&gt; for key user_details'
  </code></pre>
  
  <ul>
  <li>So, Why I'm not able to store the object of type <code>UserDetails</code>. </li>
  <li>What is the actual type of <code>AnyObject</code></li>
  <li>Why it is thrown <code>InvalidArgumentException</code>.</li>
  </ul>
  
  <p>I really need to the difference and What type of objects <code>AnyObject</code> can handle?</p>
  
  <p>Thank you.</p>