我正在学习一些关于使用swift的HealthKit的教程,我正在学习的教程之一是如何从HealthKit中检索一些数据,例如体重、高度、年龄。本教程展示了如何为它们检索最近的记录,以下代码展示了:funcreadMostRecentSample(sampleType:HKSampleType,completion:((HKSample!,NSError!)->Void)!){//1.BuildthePredicateletpast=NSDate.distantPast()as!NSDateletnow=NSDate()letmostRecentPredicate=HKQuery.pr
我正在尝试执行一些由AppleHealthKit更改触发的操作,这些操作是在我的SwiftiOS应用程序后台触发的。这是我的AppDelegate:varhealthManager:HealthManager?funcapplication(application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[NSObject:AnyObject]?)->Bool{healthManager=HealthManager.sharedInstancereturntrue}在HealthManager类的初始化中,我授权
在我当前的项目中,我需要将HealthKit样本与我的应用程序同步。我正在从HealthKit获取示例数据并将一些应用程序生成的示例写回HealthKit。为了获取,我使用了以下函数:-privatefuncreadHealthKitSample(sampleType:HKSampleType,limit:Int,startDate:NSDate,endDate:NSDate,completion:(([HKSample]?,NSError!)->Void)!){letmostRecentPredicate=HKQuery.predicateForSamplesWithStartDat
我正在学习一些关于使用swift的HealthKit的教程,我正在学习的教程之一是如何从HealthKit中检索一些数据,例如体重、高度、年龄。本教程展示了如何为它们检索最近的记录,以下代码展示了:funcreadMostRecentSample(sampleType:HKSampleType,completion:((HKSample!,NSError!)->Void)!){//1.BuildthePredicateletpast=NSDate.distantPast()as!NSDateletnow=NSDate()letmostRecentPredicate=HKQuery.pr