title: Swift: Change object with property in array
body: <p>I am trying to amend an object in my AnyObject (savedProgram). I want to save  Taking the advice from another thread, I've used 'as!' to convert it to [AnyObject]:</p>
  
  <pre><code>    @IBAction func saveM(sender: UIButton) {
      brain.variableValues["M"] = displayValue
      savedProgram = brain.program as! [AnyObject]
      var indexValue = savedProgram?.indexOfObject("M")
      savedProgram?[indexValue!] = displayValue
  </code></pre>
  
  <p>It complains at the 4th row. I've also tried changing the original variable savedProgram to [AnyObject] but then I am not sure how to look up "M" and amend it.</p>
  
  <p>Thanks for your help.</p>