     
     @IBOutlet weak var lblSteps: UILabel!
     
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
-  
-  
+        self.loadWeightArray()
+        self.selectUserWeight()
         self.stepCounter = StepCounter(healthStore: healthStore, delegate: self);
-      
+        
     }
   
     override func viewDidAppear(animated: Bool) {

    }
    
    func selectedRowInComponent(component: Int) -> Int {
        return 2
    }



    
    }
    
    func loadWeightArray() {
        for (var i = defaultUserWeight; i <= maxUserWeight; i++)
        {
            kgArray.append(String(i));
        }
    }
    
    func selectUserWeight() {
        let past : NSDate = NSDate.distantPast() as NSDate
        let now = NSDate()
        let mostRecentPredicate = HKQuery.predicateForSamplesWithStartDate(past, endDate: now, options: HKQueryOptions.None)
        let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false);
        let idWeight = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
        let sampleQuery = HKSampleQuery(sampleType: idWeight, predicate: mostRecentPredicate, limit: 0, sortDescriptors: [sortDescriptor], resultsHandler:
            {(_,results,_) -> Void in
                
                if (results != nil) {
                    let sample = results.first as HKQuantitySample
                    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)
                        
                    })
                }
        })
        
        healthStore.executeQuery(sampleQuery)
    }
}

