Tuesday, January 26, 2016

Swift: Request Authorization to Dietary Potassium Data

Swift

@IBOutlet weak var aButton: UIButton!

@IBAction func buttonTapped(sender : AnyObject){

let healthKitStore:HKHealthStore = HKHealthStore()

let healthKitTypesToWrite = Set(
arrayLiteral: HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryPotassium)! )

healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes:nil){ (success, error) -> Void in
if success == false {
}
}

}