title: swift mutating method sent to immutable object
body: <p>I just can't wrap my head around this error, I am trying to add a string to an array like I always do in objective-c, but swift gives me a weird error. </p>
  
  <pre><code>var fileArray:NSMutableArray = []
  
  alert.addAction(UIAlertAction(title: "Done", style: UIAlertActionStyle.Default, handler:{ (UIAlertAction)in
              self.fileArray.addObject(self.urlTextField.text)
              self.processURL()
          }))
  </code></pre>
  
  <p>ERROR:<br>
  <strong>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'</strong></p>
  
  <p>How <code>fileArray</code> is immutable? I declare it as MutableArray !!!!!!</p>
  
  <p>EDIT:::
  so turns out problem is the way I populate the array </p>
  
  <pre><code>fileArray = myDict?.valueForKey("fileList") as! NSMutableArray
  </code></pre>
  
  <p>this solved the problem</p>
  
  <pre><code>fileArray = myDict?.valueForKey("fileList")!.mutableCopy() as! NSMutableArray
  </code></pre>