如何从 HKHealthStore 中删除多个对象?
Posted
技术标签:
【中文标题】如何从 HKHealthStore 中删除多个对象?【英文标题】:How can i delete multiple objects from HKHealthStore? 【发布时间】:2014-10-01 20:39:29 【问题描述】:我知道有这些方法,根据Apple HealthKit Docs
Working with HealthKit Objects
deleteObject:withCompletion:
saveObject:withCompletion:
saveObjects:withCompletion:
我正在寻找这样的东西:
deleteObjects:withCompletion:
或者一种从HKHealthStore
中删除多个对象而无需多次调用deleteObject:withCompletion:
的方法。
【问题讨论】:
为什么不用t you want to call it multiple times? You could do it with a for loop, count the number of calls of the completion function, and once it reaches the number of objects you wanted to delete, call the
real`补全函数。
【参考方案1】:
在 ios 8 中,删除多个对象的唯一方法是多次调用 deleteObject:withCompletion
。但是,在 iOS 9 中,有两种新方法可用于一次删除多个对象。尝试使用deleteObjects:withCompletion:
或deleteObjectsOfType:predicate:withCompletion:
。
【讨论】:
以上是关于如何从 HKHealthStore 中删除多个对象?的主要内容,如果未能解决你的问题,请参考以下文章
HKHealthStore deleteObject 和 HKCorrelations
HKHealthStore deleteObject 和 HKCorrelations
为啥我的 HKHealthStore.DeleteObjectAsync 方法没有在 Xamarin 中执行和返回对象?