title: iOS: how to convert NSUserDefaults stored AnyObject type to array
body: <p>I have put an array into NSUserDefaults() like so:</p>
  
  <pre><code>NSUserDefaults.standardUserDefaults().setObject(users, forKey: "usersArray")
  NSUserDefaults.standardUserDefaults().synchronize()
  </code></pre>
  
  <p>Then I pull it out like so:</p>
  
  <pre><code>fetchedUserArray = NSUserDefaults.standardUserDefaults().objectForKey("usersArray")
  </code></pre>
  
  <p>The problem I am facing is that once it is removed from NSUserDefaults it is of type NSArray, preventing me from manipulating it like a Swift array. I have tried this to convert the type, however the compiler does not recognize the variable "castedUsersArray" when it is used later in the code despite not raising any errors upon type casting:</p>
  
  <pre><code>var fetchedArray = NSUserDefaults.standardUserDefaults().objectForKey("usersArray") as? NSArray
  var castedUsersArray = fetchedArray as AnyObject as [String]
  </code></pre>
  
  <p>I have spent a very long time on this with no success. The type constraints of Swift are driving me nuts.<br>
  Thank you,<br>
  Nick</p>