title: Firebase restoring initial values in textfields after changing text value
body: <p>I am practicing iOS (Swift) with Firebase. the first viewcontroller retrieves all the records from firebase db and populate the tableView from an array. when the user selects an item from that tableview a new viewcontroller pops up segueing the object from the listView viewcontroller to the detail viewcontroller. data is populated to the fields successfully! </p>
  
  <p>however when i try to update any of the textfield, the moment i switch to another textfield the initial value is restored in the edited textfield.</p>
  
  <p>I have tried to removeAllObservers... but nothing worked. i even removed "import Firebase" and all associated objects and still it restores the initial value.</p>
  
  <p>am i missing any concept here? </p>
  
  <p>this is the code from the ListViewController:</p>
  
  <pre><code>    override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated);
  
      self.activityIndicator.startAnimating();
  
      self.observeIngrdUpdates = ref.observeEventType(.Value, withBlock: { (snapshot) in
          self.ingredients.removeAll();
  
          for child in snapshot.children {
              var nutrition:String = "";
              var type:Int = 0;
              var desc:String = "";
              var img:String = "";
              var name:String = "";
              var price:Double = 0.0;
  
              if let _name = child.value["IngredientName"] as? String {
                  name = _name;
              }
  
              if let _nutrition = child.value["NutritionFacts"] as? String {
                  nutrition = _nutrition;
              }
  
              if let _type = child.value["IngredientType"] as? Int {
                  type = _type;
              }
  
              if let _desc = child.value["UnitDescription"] as? String {
                  desc = _desc;
              }
  
              if let _img = child.value["IngredientImage"] as? String {
                  img = _img;
              }
  
              if let _price = child.value["IngredientPrice"] as? Double {
                  price = _price;
              }
  
              let ingredient = Ingredient(name: name, type: type, image: img, unitDesc: desc, nutritionFacts: nutrition, price: price);
              ingredient.key = child.key;
  
              self.ingredients.append(ingredient);
  
          }
          self.tableView.reloadData();
      })
  }
  </code></pre>
  
  <p>and the PrepareForSegue:</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      let destinationVC = segue.destinationViewController as! EditIngredientVC;
      if segue.identifier?.compare(SEGUE_EDIT_INGREDIENTS) == .OrderedSame {
          destinationVC.ingredient = ingredients[tableView.indexPathForSelectedRow!.row];
          destinationVC.controllerTitle = "Edit";
      } else if segue.identifier?.compare(SEGUE_ADD_INGREDIENT) == .OrderedSame {
          destinationVC.controllerTitle = "New";
      }
  }
  </code></pre>
  
  <p>this is the code for populating the fields in DetailViewController:</p>
  
  <pre><code>override func viewDidLayoutSubviews() {
      lblControllerTitle.text = controllerTitle;
      if controllerTitle?.localizedCaseInsensitiveCompare("NEW") == .OrderedSame {
          self.segVegFru.selectedSegmentIndex = 0;
  
      } else {
  
          if ingredient != nil {
              self.txtIngredientName.text = ingredient!.name;
              self.txtUnitDesc.text = ingredient!.unitDesc;
              self.segVegFru.selectedSegmentIndex = ingredient!.typeInt;
              self.txtNutritionFacts.text = ingredient!.nutritionFacts;
              self.txtPrice.text = "\(ingredient!.price)";
          }
      }
  }
  </code></pre>
  
  <p>Thank you all for your help.</p>