gpt4 book ai didi

ios - WatchKit App 只返回一些 HealthKit 数据

转载 作者:行者123 更新时间:2023-11-29 01:38:01 25 4
gpt4 key购买 nike

我的 IOS 应用程序和 WatchKit 应用程序 (Xcode 7 GM) 中都运行了以下方法。 IOS 应用程序返回我所有的运行锻炼,但是 Watchkit 应用程序只返回前 2 个运行锻炼。

有什么想法吗?

func readRunningWorkOuts(completion: (([AnyObject]!, NSError!) -> Void)!) {

// 1. Predicate to read only running workouts
let predicate = HKQuery.predicateForWorkoutsWithWorkoutActivityType(HKWorkoutActivityType.Running)
// 2. Order the workouts by date
let sortDescriptor = NSSortDescriptor(key:HKSampleSortIdentifierStartDate, ascending: false)
// 3. Create the query
let sampleQuery = HKSampleQuery(sampleType: HKWorkoutType.workoutType(), predicate: predicate, limit: 0, sortDescriptors: [sortDescriptor])
{ (sampleQuery, results, error ) -> Void in

if let queryError = error {
print( "There was an error while reading the samples: \(queryError.localizedDescription)")
}
completion(results,error)
}
// 4. Execute the query
healthKitStore.executeQuery(sampleQuery)

}

最佳答案

只能从 watch 上的 HealthKit 获取最近 7 天的数据。在此之前创建的任何锻炼都只会在手机上进行。查看HKHealthStore reference获取更多信息。

关于ios - WatchKit App 只返回一些 HealthKit 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32742156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com