title: Cannot convert value of type 'ReverseRandomAccessCollection<[AnyObject]>’ to type '[PFObject]' in coercion
body: <p>Using Parse. I've had to edit some older Swift to Swift 2 and most of it looks good except for the line with the error. There could be other reasons for the error but I'm not sure. If no one has a fix for this I can post more code later to see if it helps the question.  Error point is commented. </p>
  
  <p>Two errors on the same line: </p>
  
  <blockquote>
    <p>Cast from 'ReverseRandomAccessCollection&lt;[AnyObject]>' (aka 'ReverseRandomAccessCollection>') to unrelated type '[PFObject]' always fails    </p>
    
    <p>Cannot assign value of type '[PFObject]' to type 'NSMutableArray'</p>
  </blockquote>
  
  <pre><code>class TimelineTableViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
  
  var timelineData:NSMutableArray = NSMutableArray()
  
  override init(style: UITableViewStyle) {
      super.init(style: style)
      // Custom initialization
  }
  
  required init(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)!
  }
  
  override func viewDidAppear(animated: Bool) {
  
      let footerView:UIView = UIView(frame: CGRectMake(0, 0, self.view.frame.size.width, 50))
      self.tableView.tableFooterView = footerView
  
      //let logoutButton:UIButton = UIButton.buttonWithType(UIButtonType.System) as UIButton // legacy
      // let logoutButton = UIButton(type: UIButtonType.System) as UIButton // Swift 1.5
      let logoutButton = UIButton(type: .System) as UIButton // Swift 2 convenience init
      logoutButton.frame = CGRectMake(20, 10, 50, 20)
      logoutButton.setTitle("Logout", forState: UIControlState.Normal)
      logoutButton.addTarget(self, action: "logout:", forControlEvents: UIControlEvents.TouchUpInside)
  
      footerView.addSubview(logoutButton)
  
  
      if ((PFUser.currentUser() == nil)){
          self.showLoginSignUp()
      }
  
  }
  
  func showLoginSignUp(){
      let loginAlert:UIAlertController = UIAlertController(title: "Sign Up / Login", message: "Please sign up or login", preferredStyle: UIAlertControllerStyle.Alert)
  
      loginAlert.addTextFieldWithConfigurationHandler({
          textfield in
          textfield.placeholder = "Your username"
          })
  
      loginAlert.addTextFieldWithConfigurationHandler({
          textfield in
          textfield.placeholder = "Your password"
          textfield.secureTextEntry = true
          })
  
      loginAlert.addAction(UIAlertAction(title: "Login", style: UIAlertActionStyle.Default, handler: {
          alertAction in
          let textFields:NSArray = loginAlert.textFields! as NSArray
          let usernameTextfield:UITextField = textFields.objectAtIndex(0) as! UITextField
          let passwordTextfield:UITextField = textFields.objectAtIndex(1) as! UITextField
  
          PFUser.logInWithUsernameInBackground(usernameTextfield.text, password: passwordTextfield.text){
              (user:PFUser!, error:NSError!)-&gt;Void in
              if ((user) != nil){
                  print("Login successfull")
                  let installation:PFInstallation = PFInstallation.currentInstallation()
                  installation.addUniqueObject("Reload", forKey: "channels")
                  installation["user"] = PFUser.currentUser()
                  installation.saveInBackground()
  
              }else{
                  print("Login failed")
              }
  
          }
  
          }))
  
      loginAlert.addAction(UIAlertAction(title: "Sign Up", style: UIAlertActionStyle.Default, handler: {
          alertAction in
          let textFields:NSArray = loginAlert.textFields! as NSArray
          let usernameTextfield:UITextField = textFields.objectAtIndex(0) as! UITextField
          let passwordTextfield:UITextField = textFields.objectAtIndex(1) as! UITextField
  
          let sweeter:PFUser = PFUser()
          sweeter.username = usernameTextfield.text
          sweeter.password = passwordTextfield.text
  
          sweeter.signUpInBackgroundWithBlock{
              (success:Bool!, error:NSError!)-&gt;Void in
              if (error == nil){
                  print("Sign Up successfull")
                  let imagePicker:UIImagePickerController = UIImagePickerController()
                  imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
                  imagePicker.delegate = self
  
                  self.presentViewController(imagePicker, animated: true, completion: nil)
  
                  let installation:PFInstallation = PFInstallation.currentInstallation()
                  installation.addUniqueObject("Reload", forKey: "channels")
                  installation["user"] = PFUser.currentUser()
                  installation.saveInBackground()
  
  
              }else{
                  let errorString = error.userInfo["error"] as! NSString
                  print(errorString)
              }
  
          }
  
          }))
  
      self.presentViewController(loginAlert, animated: true, completion: nil)
  }
  
  func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
  
      // let pickedImage:UIImage = info.objectForKey(UIImagePickerControllerOriginalImage) as! UIImage - old syntax
      let pickedImage:UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
  
      // Scale down image
      let scaledImage = self.scaleImageWith(pickedImage, and: CGSizeMake(100, 100))
  
      let imageData = UIImagePNGRepresentation(scaledImage)
  
      let imageFile:PFFile = PFFile(data: imageData)
  
      PFUser.currentUser().setObject(imageFile, forKey: "profileImage")
      PFUser.currentUser().saveInBackground()
  
      picker.dismissViewControllerAnimated(true, completion: nil)
  }
  
  func scaleImageWith(image:UIImage, and newSize:CGSize)-&gt;UIImage{
      UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
      image.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height))
      let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
  
      return newImage
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.loadData()
  
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "loadData", name: "reloadTimeline", object: nil)
  
  }
  
  @IBAction func loadData(){
  
      timelineData.removeAll(keepCapacity: false)
  
      let findTimelineData:PFQuery = PFQuery(className:"Sweets")
      findTimelineData.findObjectsInBackgroundWithBlock
          {
              (objects:[AnyObject]! , error:NSError!) -&gt; Void in
              if error == nil
              {
                  self.timelineData = objects.reverse() as [PFObject] // error
  
                  print(objects)
  
                  self.tableView.reloadData()
              }
      }
  }
  
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cell:SweetTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SweetTableViewCell
  
      //let sweet:PFObject = self.timelineData.objectAtIndex(indexPath.row) as! PFObject
      let sweet: PFObject = self.timelineData[indexPath.row] as! PFObject
  
      cell.sweetTextView.alpha = 0
      cell.timestampLabel.alpha = 0
      cell.usernameLabel.alpha = 0
  
      cell.sweetTextView.text = sweet.objectForKey("content") as! String
  
  
      let dataFormatter:NSDateFormatter = NSDateFormatter()
      dataFormatter.dateFormat = "yyyy-MM-dd HH:mm"
      cell.timestampLabel.text = dataFormatter.stringFromDate(sweet.createdAt)
  
      let findSweeter:PFQuery = PFUser.query()
      findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter").objectId)
  
      findSweeter.findObjectsInBackgroundWithBlock{
          (objects:[AnyObject]!, error:NSError!)-&gt;Void in
          if (error == nil){
              let user:PFUser = (objects as NSArray).lastObject as! PFUser
              cell.usernameLabel.text = user.username
  
              // Profile Image
              cell.profileImageView.alpha = 0
  
              let profileImage:PFFile = user["profileImage"] as! PFFile
  
              profileImage.getDataInBackgroundWithBlock{
                  (imageData:NSData!, error:NSError!)-&gt;Void in
  
                  if (error == nil){
                      let image:UIImage = UIImage(data: imageData)!
                      cell.profileImageView.image = image
                  }
  
              }
  
              UIView.animateWithDuration(0.5, animations: {
                  cell.sweetTextView.alpha = 1
                  cell.timestampLabel.alpha = 1
                  cell.usernameLabel.alpha = 1
                  cell.profileImageView.alpha = 1
              })
          }
      }
  
  
      return cell
  }
  }
  </code></pre>