Ayaan
Ayaan

Reputation: 57

Swift ResearchKit HealthKit QuestionStep

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)'

Upvotes: 0

Views: 199

Answers (1)

jwe
jwe

Reputation: 436

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

Upvotes: 2

Related Questions