0
我想记录一个3位的NSNumber健康套件作为PeakExpiratoryFlowRate,代码如下保存PeakExpiratoryFlowRate HealthKit记录
- (void)PeakFlowupdate:(NSNumber *)pkFlow
{
NSString *identifier = HKQuantityTypeIdentifierPeakExpiratoryFlowRate;
HKQuantityType *peakFlowType = [HKObjectType quantityTypeForIdentifier:identifier];
HKQuantity *myPeakFlow = [HKQuantity quantityWithUnit:[HKUnit minuteUnit] doubleValue:[pkFlow doubleValue]];
HKQuantitySample *peakFlowSample = [HKQuantitySample quantitySampleWithType:peakFlowType quantity:myPeakFlow startDate:[NSDate date] endDate:[NSDate date]];
[healthStore saveObject:peakFlowSample withCompletion:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"SAVED!");
} else {
NSLog(@"%@", error);
}
}];
}
但是当我尝试将数据保存到医疗包我收到此错误
终止应用程序由于未捕获的异常 “_HKObjectValidationFailureException”,原因:“HKQuantitySample 250 分钟2016年6月22日10时32分24秒1200 2016年6月22日10时32分24秒1200需要单元类型为Volume/Time的 。不兼容的单位:分钟