     }
   
   
-    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 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)
-        
     }
 }
 

        
        healthStore.executeQuery(sampleQuery)
    }
    
    func saveUserWeight(weight:Double) {
        let bmType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
        let bmQuantity = HKQuantity(unit: HKUnit.gramUnit(), doubleValue:  weight * 1000 )

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
      
        var ad = UIApplication.sharedApplication().delegate as AppDelegate
        healthStore = ad.healthStore;
        self.loadWeightArray()
//        self.selectUserWeight()
        self.stepCounter = StepCounter(healthStore: healthStore, delegate: self);
      
      healthStore.requestAuthorizationToShareTypes(dataTypesToWrite(), readTypes: dataTypesToRead(), completion: {
        (success:Bool, error:NSError!) -> Void in
        //      if !success{
        //        var alert = UIAlertView(title: "Missed authorization", message: "The app cannot work without authorization for HealthKit. Closing", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "Close")
