title: Swift Parse Relation on Cell Button Click Error
body: <p>I am using a button within a tableview cell to create a relationship between the currently logged in user and the user who is displayed within the tableview cell that has been clicked. I have been able to create the action functionality for this tableview cell button and can confirm that the click is registered because of my log, but the else statement of my Parse save block is being triggered with the value of <code>nil</code>. Am I trying to establish this relationship incorrectly with my parse code?</p>
  
  <p>TableView code:</p>
  
  <pre><code>import UIKit
  
  class SearchUsersRegistrationTableViewController: UITableViewController {
  
      var userArray : NSMutableArray = []
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          var user = PFUser.currentUser()
  
          loadParseData()
  
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      // MARK: - Table view data source
  
      override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
  
          return 1
  
      }
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
          return userArray.count
  
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
          let cell: SearchUsersRegistrationTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SearchUsersRegistrationTableViewCell
  
          cell.addUserButton.tag = indexPath.row
          cell.addUserButton.addTarget(self, action: "addUser:", forControlEvents: .TouchUpInside)
  
          let users: PFObject = self.userArray.objectAtIndex(indexPath.row) as! PFObject
  
          if let user : PFUser = users as? PFUser {
              cell.usernameLabel.text = user.username
  
              println("user exist")
  
              if let userImage : PFFile = user["profileImage"] as? PFFile {
  
                  userImage.getDataInBackgroundWithBlock{
                      (imageData: NSData!, error: NSError!) -&gt; Void in
  
                      if error != nil {
  
                          let image: UIImage = UIImage(data: imageData)!
  
                          cell.userImage.image = image as UIImage
  
                      }
  
                  }
  
              } else {
  
                  cell.userImage.image = UIImage(named: "profileImagePlaceHolder")
  
              }
  
          }
          return cell
      }
  
      func loadParseData() {
  
          var query : PFQuery = PFUser.query()
  
          query.findObjectsInBackgroundWithBlock {
              (objects:[AnyObject]!, error:NSError!) -&gt; Void in
  
              if error == nil {
  
                  if let objects = objects {
  
                      println("\(objects.count) users are listed")
  
                      for object in objects {
  
                          self.userArray.addObject(object)
  
                      }
                      self.tableView.reloadData()
                  }
              } else {
                  println("There is an error")
              }
          }
      }
  
      @IBAction func addUser(sender: AnyObject) {
  
          println("Button Triggered")
  
          let addUserButton : UIButton = sender as! UIButton
  
          let user : PFObject = self.userArray.objectAtIndex(addUserButton.tag) as! PFObject
  
          var relation : PFRelation = PFUser.currentUser().relationForKey("Followers")
  
          relation.addObject(user)
  
          PFUser.currentUser().saveInBackgroundWithBlock {
              (succeed:Bool, error: NSError!) -&gt; Void in
              if error != nil {
  
                  println("Added User")
  
              } else {
  
                  println(error)
  
              }
  
          }
      }
  
  }
  </code></pre>
  
  <p>TableView Cell:</p>
  
  <pre><code>import UIKit
  
  class SearchUsersRegistrationTableViewCell: UITableViewCell {
  
  
  
      @IBOutlet weak var userImage: UIImageView!
      @IBOutlet weak var usernameLabel: UILabel!
      @IBOutlet weak var addUserButton: UIButton!
  
  
      override func awakeFromNib() {
          super.awakeFromNib()
  
          userImage.layer.borderWidth = 1
          userImage.layer.masksToBounds = false
          userImage.layer.borderColor = UIColor.whiteColor().CGColor
          userImage.layer.cornerRadius = userImage.frame.width/2
          userImage.clipsToBounds = true
  
  
      }
  
      override func setSelected(selected: Bool, animated: Bool) {
          super.setSelected(selected, animated: animated)
  
          // Configure the view for the selected state
      }
  
  
  
  }
  </code></pre>
  
  <p>UPDATE: The data is actually being sent correctly to parse, but I'm not sure why my else statement is firing.</p>
  
  <p><img src="https://i.stack.imgur.com/EqsHv.png" alt="relation"></p>