从 swift 1.2 迁移后 swift2 中的 healthKit 错误

healthKit error in swift2 after migration from swift 1.2

我有这段代码在 Swift 1.2 中请求写入权限,在升级到 Swift 2.0 后我收到一个奇怪的错误: ... '_' is not convertible to 'HKWorkoutType'

出现错误的代码行:

let healthKitTypesToWrite = Set(arrayLiteral:[
        HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
        HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning),
        HKQuantityType.workoutType()
        ])

有什么想法吗?

前两项添加!

let healthKitTypesToWrite = Set(arrayLiteral:
[
    HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)!, 
    HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning)!, 
    HKQuantityType.workoutType() 
])

这是必需的,因为 quantityTypeForIdentifier returns HKQuantityType?