title: Cannot assign value of type NSMutableArray to type UIBarButtonItem
body: <p>I am developing an iOS audio app as a learning project. I'm having a problem in one of the functions, which checks if the player is playing or paused/stopped. If it's playing it should change the button in the button bar to a "pause" button, or if it's paused or stopped, change the button to a "play" button. I am assigning the button bar items to a variable "items" as a NSMutableArray, then make the necessary change to the button, then assign "items" back to the button bar items to update the display.</p>
  
  <p>In my code I am getting an error on the line:</p>
  
  <pre><code>self.toolbar.items = items
  </code></pre>
  
  <p>The error message is </p>
  
  <blockquote>
    <p>Cannot assign value of type NSMutableArray to Type UIBarButtonItem</p>
  </blockquote>
  
  <p>I assume that I need to cast the NSMutableArray, I've tried using Array, and when I do the error goes away but the buttons break. </p>
  
  <p>The related parts of my code are:</p>
  
  <pre><code>@IBOutlet weak var toolbar: UIToolbar!
  
  @IBOutlet var playButton: UIBarButtonItem!
  
  
  @IBAction func playPausePressed(sender: AnyObject) {
      let playbackState = self.player.playbackState as MPMusicPlaybackState
      let items = NSMutableArray(array: self.toolbar.items!)
      if playbackState == .Stopped || playbackState == .Paused{
          self.player.play()
          items[2] = self.pauseButton
      } else if playbackState == .Playing{
          self.player.pause()
          items[2] = self.playButton
      }
      self.toolbar.items = items
  }
  </code></pre>
  
  <p>Any help or direction would be much appreciated.
  Thanks!</p>