【问题标题】:HKHealthStore deleteObjects reporting Error Domain=com.apple.healthkit Code=100 "Transaction failure."HKHealthStore deleteObjects 报告错误 Domain=com.apple.healthkit Code=100 “交易失败。”
【发布时间】:2016-02-12 09:27:24
【问题描述】:

我正在尝试使用 HKHealthStore deleteObjects 一次性删除大约 400 个对象,而我'我遇到了这个奇怪的错误。

Error Domain=com.apple.healthkit Code=100 "交易失败。"

代码如下:

self.healthKitStore.deleteObjects(deleteQ, withCompletion: { (success, error) -> Void in
})

有什么想法吗? 谢谢!

【问题讨论】:

  • 显示代码如何从 healthkit 中删除对象
  • 添加了一行...
  • 你删除什么类型的对象?它们是否像锻炼和相应的样本一样相互关联?您是否使用自己的应用程序创建了对象?您是选择了对象还是在创建对象后没有选择就删除了它们?

标签: ios swift healthkit


【解决方案1】:

有时,如果您在保存或删除样本之前不是requestAuthorizationToShareTypes,HealthKit 会给您这个错误。

【讨论】:

  • 这没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker。 - From Review
  • 比如说,如果你想删除一些心率样本,你应该在删除前请求授权。让 heartRateType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)!让 readTypes = Set([heartRateType]) healthStore.requestAuthorizationToShareTypes(nil, readTypes: readTypes) { 成功,self.healthKitStore.deleteObjects 中的错误(deleteQ, withCompletion: { (success, error) -> Void in }) }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-31
  • 2018-07-18
  • 1970-01-01
  • 2021-05-11
  • 1970-01-01
  • 2021-04-15
  • 1970-01-01
相关资源
最近更新 更多