title: Set a childByAutoId value in Firebase data service class to be retrieved in another class
body: <p>Hopefully I can make this more clear than my title. I created a FirebaseService class. In it I will create all of the methods for saving and retrieving data. I don't want to have to make a firebase reference in any other class. I simply want to reference this class to do that. If this isn't possible, please let me know so I don't move forward with it. Below is my FirebaseService class...</p>
  
  <pre><code>import UIKit
  import Firebase
  
  class FirebaseService: NSObject {
  
      let ref = FIRDatabase.database().reference()
      var id = String()
  
  
      func savePost(post:[String:AnyObject]) {
          let postRef = ref.child("posts").childByAutoId()
          id = postRef.key
          postRef.setValue(post)
  
      }
  
  
  
  }
  </code></pre>
  
  <p>I want to be able to retrieve <code>id</code> from the FirebaseService class and have it actually use the value of childByAutoId (the post's randomly generated id in Firebase) when I save a post so I can save it as a value in post called "id". However, right now when I save it, I get an intended random id generated for the post as a whole but I don't get that value in my "id" key.</p>
  
  <pre><code>func postPost() {
      post.id = FirebaseService().id
      post.textContent = textView.text
      post.name = "Michael Williams"
      post.profileImageName = "cool"
      post.imageContentName = "coffee"
      post.createdDate = convertCurrentTimeToString()
      let postArray:[String:AnyObject] = ["name":post.name!, "profileImageName":post.profileImageName!, "textContent":post.textContent!, "imageContentName":post.imageContentName!, "createdDate":post.createdDate!, "id":post.id!]
      dismissViewControllerAnimated(true) {
          FirebaseService().savePost(postArray)
      }
  }
  </code></pre>
  
  <p>Firebase database scheme:</p>
  
  <ul>
  <li><p>Posts   "randomly generated id"</p>
  
  <ul>
  <li><p>name: "John Doe"</p></li>
  <li><p>id: same randomly generated id as above</p></li>
  <li><p>postText: "Blah Blah"</p></li>
  </ul></li>
  </ul>
  
  <p>Again, all I am getting for id is an empty string when I run the <code>postPost()</code> function.</p>