在线
var anchor = HKQueryAnchor(fromValue: Int(HKAnchoredObjectQueryNoAnchor))
我收到的红旗错误
无法将"Int"类型的值转换为预期的参数类型"Uint"
我复制粘贴了另一个Xcode项目的代码,这在另一个项目中没有给这行带来错误(仅在watchOS上读取心率)。
有什么想法吗?
let healthStore = HKHealthStore()
//State of the app - is the workout activated
var workoutActive = false
// define the activity type and location
var workoutSession : HKWorkoutSession?
let heartRateUnit = HKUnit(fromString: "count/min")
var anchor = HKQueryAnchor(fromValue: Int(HKAnchoredObjectQueryNoAnchor))
错误准确地告诉你必须做什么。只需更改代码:
var anchor = HKQueryAnchor(fromValue: UInt(HKAnchoredObjectQueryNoAnchor))
您需要将Int
更改为UInt
,这正是HKQueryAnchor
所期望的。