我如何创建一个HKCategorySample
?我正在关注文档,但出现错误
Cannot invoke 'init' with an argument list of type '(type: HKCategoryType, value: Int, startDate: NSDate, endDate: NSDate)'
文档似乎表明这些是传递它的正确参数类型,那么它实际上在抱怨什么?
我正在使用的代码是:
let sample = HKCategorySample(
type: HKCategoryTypeIdentifierSleepAnalysis as HKCategoryType,
value: HKCategoryValueSleepAnalysis.Asleep as Int,
startDate: start,
endDate: end)
其中start
和end
都是NSDate
s