                     let quantity = sample.quantity.doubleValueForUnit(HKUnit.gramUnitWithMetricPrefix(.Kilo))
                     
                     dispatch_async(dispatch_get_main_queue(), {
-                      self.userWeight = Int(quantity)
-                      self.weightPicker.selectRow(self.selectedRowInComponent(0), inComponent: 0, animated: false)
-                      
+                        self.setWeightInUI(Int(quantity))
                     })
                   }
                 }

        }
        return pos
    }


  
    /*

        
        healthStore.executeQuery(sampleQuery)
    }
    
    func saveUserWeight(weight:Double) {
        let bmType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
        let bmQuantity = HKQuantity(unit: HKUnit.gramUnit(), doubleValue:  weight * 1000 )
        let sample = HKQuantitySample(type: bmType, quantity: bmQuantity, startDate: NSDate(), endDate: NSDate())
        
        
        self.healthStore.saveObject(sample, withCompletion: {
            (success, error) in
            if !success {
                let alertController = UIAlertController(title: "Error", message: "Error saving data on HealthKit", preferredStyle: .Alert)
            } else {
                self.userWeight = Int(weight)
            }
        })
    }
    
    func setWeightInUI(weight:Int, animation: Bool = false) {
        self.userWeight = weight
        self.weightPicker.selectRow(self.selectedRowInComponent(weight), inComponent: 0, animated: animation)
    }
  
  
    private func dataTypesToRead() -> NSSet {
        var typeIds = [HKQuantityTypeIdentifierHeight, HKQuantityTypeIdentifierBodyMass, HKQuantityTypeIdentifierDistanceWalkingRunning]
        var typeBodyMass = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
        //    var type2 = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight)
        //    var type3 = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning)
        var typeStepCount = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)
        
        return NSSet(objects: typeStepCount, typeBodyMass)
        
    }
    
    private func dataTypesToWrite() -> NSSet {
        var typeBodyMass = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
        
        return NSSet(objects: typeBodyMass)
        
    }
}

