override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//***********************************************************************************************************
// requesting access and autherzation and availability
let healthStore = HKHealthStore()
if HKHealthStore.isHealthDataAvailable() {
calciumTracker.setProgress(0.1, animated: true)
let ShareTypes : Set = [HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)!]
let ReadTypes : Set = [HKCharacteristicType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex)!]
healthStore.requestAuthorizationToShareTypes(ShareTypes, readTypes: ReadTypes , completion:{
(success,error) in
if !success {
if let x = error {
print(x.description)
}
}
})
}
else {
print("Health data are not available on this device")
}
//***********************************************************************************************************
let endDate = NSDate()
let startDate = NSDate()
var v : HKQuantitySample?
let stepsCount:HKQuantityType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)!
let predicate:NSPredicate = HKQuery.predicateForSamplesWithStartDate(startDate, endDate: endDate, options: .None)
let limit = 1
let query = HKSampleQuery(sampleType: stepsCount, predicate: predicate, limit: limit, sortDescriptors: nil, resultsHandler: {
(query, results, error) in
if results == nil {
print(error)
}
v = results!.first as! HKQuantitySample?
})
healthStore.executeQuery(query)
let l = Float(v!.quantity.doubleValueForUnit(HKUnit(fromString: "count")))
stepsTracker.setProgress(l/300, animated: true)
}
when i run the app it get stuck on the launch screen and Xcode tell me there is threads an list them i do not understand any of them because i think they are in assembly language