title: Add value instead of change value In Firebase with Swift
body: <p>I would like to save and retrieve features to and from Firebase into a TableView.
  The child I would like to save them under is the uid (unique user id)</p>
  
  <p>so a feature would look like this in the database: </p>
  
  <p><a href="https://i.stack.imgur.com/Rxjrf.png" rel="nofollow noreferrer">Firebase database</a></p>
  
  <p>The ideal situation, is how the "derde" is saved, so the uid as a key and "derde" as the value.</p>
  
  <pre><code>@IBAction func saveButtonPressed(sender: AnyObject) {
  
      let featureContents = addFeatureTextField.text
  
      if featureContents != "" {
  
          // Build the new Feature.
  
  
      let newFeature: String = featureContents!
  
          let ref = DataService.dataService.FEATURE_REF.childByAppendingPath(uid)
          ref.setValue(newFeature)
  </code></pre>
  
  <p>where uid is a String, retrieved from authdata somewhere else in the code.</p>
  
  <p>If I save it like this, it saves it to the specific  uid path. If I want to add another feature by clicking on the + in the TableViewController, it saves it to the same path, so the Firebase database is updated with the new value and so instead of two features you only end up with one updated feature.</p>
  
  <p>You can prevent this by working with the chilByAutoId() method, to save a list of items. The code would look like this:</p>
  
  <pre><code>   @IBAction func saveButtonPressed(sender: AnyObject) {
  
      let featureContents = addFeatureTextField.text
  
      if featureContents != "" {
  
          // Build the new Feature.
  
  
      let newFeature: String = featureContents!
  
          let ref = DataService.dataService.FEATURE_REF.childByAutoId().childByAppendingPath(uid)
          ref.setValue(newFeature)
  </code></pre>
  
  <p>via this way, a feature is saved, as you can see in the above image at: "vierde"
  This allows you to save multiple features with all the same uid, but different autoId.</p>
  
  <p>But, if I save it like this, my tableView stays empty. The TableViewController is like this:</p>
  
  <pre><code>DataService.dataService.FEATURE_REF.observeEventType(.Value, withBlock: { snapshot in
  
          // The snapshot is a current look at our features data.
  
          print("The features in the tableView should be \(snapshot.value)")
  
          self.features = []
  
          if let snapshots = snapshot.children.allObjects as? [FDataSnapshot] {
  
  
  
              for snap in snapshots {
  
                  // Make our features array for the tableView.
  
  
  
                  if let postDictionary = snap.value as? String {
  
  
  
                      print("All in")
  
  
                      let key = snap.key
  
                      let feature = Feature(key: key, value: postDictionary)
  
                      // Items are returned chronologically, but it's more fun with the newest features first.
  
                      self.features.insert(feature, atIndex: 0)
                  }
              }
  
          }
  
          // Be sure that the tableView updates when there is new data.
  
          self.tableView.reloadData()
      })
  
  
  
  }
  </code></pre>
  
  <p>Problem lies in this code: if let postDictionary = snap.value as? String {</p>
  
  <p>This conditional binding does not succeed, because the value is not a String, but  the autoId key has no value, only the child under it which is the uid has a value "vierde"</p>
  
  <p>Two possible solutions which I am asking you guys:</p>
  
  <p>1) How can I save multiple features with the same uid without using the autoId?
  2) If I am obliged to use the autoId, how can I make sure it observes the value of the uid key under the autoId, instead of the non existing value of the autoId.</p>
  
  <p>Thanks for your help!</p>