Reputation: 535
I had this code asking for write permissions working in Swift 1.2
and after upgrading to Swift 2.0
I getting a strange error:
... '_' is not convertible to 'HKWorkoutType'
code line where error appear:
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning),
HKQuantityType.workoutType()
])
any ideas?
Upvotes: 4
Views: 249
Reputation: 9337
Add !
for first two items:
let healthKitTypesToWrite = Set(arrayLiteral:
[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)!,
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning)!,
HKQuantityType.workoutType()
])
This is required because quantityTypeForIdentifier
returns HKQuantityType?
Upvotes: 5