错误“无法将类型 'int' 的值转换为预期的参数类型 'UInt'
Error 'cannot convert value of type 'int' to expected argument type 'UInt'
在线
var anchor = HKQueryAnchor(fromValue: Int(HKAnchoredObjectQueryNoAnchor))
我收到红旗错误
cannot convert value of type 'Int' to expected argument type '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
所期望的。
在线
var anchor = HKQueryAnchor(fromValue: Int(HKAnchoredObjectQueryNoAnchor))
我收到红旗错误
cannot convert value of type 'Int' to expected argument type '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
所期望的。