0

I'm currently working on a medical research app in swift, based on the ResearchKit framework (which is written in objective-c). I'm currently trying to create a survey with a HealthKit question. The code I have as of right now is:

    let genderAnswerFormat = ORKHealthKitCharacteristicTypeAnswerFormat(characteristicType: HKCharacteristicTypeIdentifierBiologicalSex)
    let genderQuestionStepTitle = "What is your gender?"
    let genderQuestionStep = ORKQuestionStep(identifier: "genderQuestionStep", title: genderQuestionStepTitle, answer: genderAnswerFormat)
    steps += [genderQuestionStep]

However, the first line results in an error:

Cannot find an initializer for 'ORKHealthKitCharacteristicTypeAnswerFormat' that accepts an argument list of type '(characteristicType: String)'

Ayaan
  • 57
  • 7

1 Answers1

2

You need to convert the identifier to an HKObjectType, which is the expected argument type of the initializer.

jwe
  • 436
  • 2
  • 4