title: Save current user's message list in parse with swift
body: <p>I use parse for my app. I want to let user able to type messages that they want to send via textField and save it to that user's messages column in parse with <code>PFRelation</code> via save button in view controller and the messages will be saved as an array and show it in <code>tableView</code>.</p>
  
  <p>The problem is I don't know how to add text in textfield to an array and save it to parse. </p>
  
  <p>Any help is appreciated and let me know if you need any additional information! </p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><a href="https://www.dropbox.com/s/6xp48v3yn0l2hje/Screen%20Shot%202015-06-03%20at%202.10.13%20PM.png?dl=0" rel="nofollow noreferrer">These</a> are screenshots of my parse's class "User" </p>
  
  <p><a href="https://www.dropbox.com/s/pd8mt8sf35u1m0v/Screen%20Shot%202015-06-03%20at%202.10.55%20PM.png?dl=0" rel="nofollow noreferrer">This</a> is my current user's friend list inside "Friends" column </p>
  
  <p>I've not yet create Messages column because when run <code>relationForKey</code> code in Xcode it will automatically create for me</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>This is my code:</p>
  
  <pre><code>@IBAction func addMessage(sender: AnyObject) {
      var newMessage = addMessageText.text
      let message = PFObject(className: "Messages")
      var query = PFQuery(className: "Messages")
      message["messageTextColumn"] = newMessage
  
  
  
      message.saveInBackgroundWithBlock {
          (success: Bool, error: NSError?) -&gt; Void in
          if (success) {
  
  
              println("added to Message Class")
              query.whereKey("messageTextColumn", equalTo: newMessage)
              query.getFirstObjectInBackgroundWithBlock{(object:PFObject!, error: NSError!) -&gt; Void in
                  if error == nil {
                      let relation = PFUser.currentUser().relationForKey("Messages")
                      var addMessageWithObject = object
                      if addMessageWithObject != nil {
                          relation.addObject(addMessageWithObject)
                          println("Added with getFirstObject")
                      }
                      else{
                          println("Error Added with getFirstObject")
                      }
                  }
              }
  
  
  
          } else {
              println("added to Message class Error")
          }
      }
      }
  </code></pre>
  
  <p>I save new message to the array first and then I save it with saveInBackgroundWithBlock.. and inside I query that message to add it to relation. </p>
  
  <p>The messages that I've added appear on Messages class table but not in that user's relation but it shows log </p>
  
  <pre><code>"added to Message Class" and "Added with getFirstObject"  
  </code></pre>
  
  <p>Which means that my code execute exactly like it should be. Probably about the method?<br>
  <strong>UPDATE 3</strong> this is the object println</p>
  
  <pre><code>&lt;Messages: 0x7fd4484f75f0, objectId: LFXoSaHfQl, localId: (null)&gt; {
  ACL = "&lt;PFACL: 0x7fd4484d2e70&gt;";
  messageTextColumn = 9;
  </code></pre>
  
  <p>}</p>
  
  <p><strong>UPDATE 4</strong> 
  this is my code </p>
  
  <pre><code>@IBAction func addMessage(sender: AnyObject) {
      var newMessage = addMessageText.text
      let message = PFObject(className: "Messages")
      var user = PFUser.currentUser()
      var query = PFQuery(className: "Messages")
      message["messageTextColumn"] = newMessage
  
          message.saveInBackgroundWithBlock {
              (success: Bool, error: NSError?) -&gt; Void in
              if (success) {
  
  
                  println("added to Message Class")
                  query.getFirstObjectInBackgroundWithBlock{(object:PFObject!, error: NSError!) -&gt; Void in
                      if error == nil {
                          var addMessageWithObject = object
                          if addMessageWithObject != nil {
                              user.saveInBackground()
                              println("Added with getFirstObject")
                          }
                          else{
                              println("Error Added with getFirstObject")
                          }
                      }
                  }
              }
      }
  }
  </code></pre>
  
  <p>user column is (undefined) as in screenshot here 
  <img src="https://i.stack.imgur.com/2Itph.png" alt="Messages class table"><br>
  and the error log <code>can't add non pointer to relation</code>  is back</p>
  
  <p>how do I fix this? Thanks!</p>