Apple Health에서 생일을 업데이트하고 싶습니다. 하지만 어떻게해야할지 모르겠다.Swift HealthKit 업데이트 생일
이 내 인증 FUNC입니다 : 내 함수를 호출
private func requestAuthorisationForHealthStore() {
let dataTypesToWrite = [
HKCharacteristicType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth),
HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass),
HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight)
]
let dataTypesToRead = [
HKCharacteristicType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth),
HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass),
HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight)
]
self.healthStore?.requestAuthorizationToShareTypes(NSSet(array: dataTypesToWrite),
readTypes: NSSet(array: dataTypesToRead), completion: {
(success, error) in
if success { println("User completed authorisation request.") }
else { println("The user cancelled the authorisation request. \(error)") }
})
}
생일을 요청하는 경우 :
func requestAgeAndUpdate() {
var error: NSError?
let dob = self.healthStore?.dateOfBirthWithError(&error)
if error != nil {
println("There was an error requesting the date of birth: \(error)")
return
}
self.ageLabel.text = "\(dob)"
}
하지만 변경하는 방법/프로그래밍 생일을 업데이트?
도움 주셔서 감사합니다.