Swift ResearchKit HealthKit QuestionStep

时间:2015-07-03 20:51:51

标签: ios swift health-kit researchkit

我目前正在研究基于ResearchKit框架(用Objective-c编写)的swift医学研究应用程序。我目前正在尝试使用HealthKit问题创建调查。我现在的代码是:

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

但是,第一行会导致错误:

找不到' ORKHealthKitCharacteristicTypeAnswerFormat'的初始值设定项。接受类型'(characteristicType:String)'

的参数列表

1 个答案:

答案 0 :(得分:2)

您需要将标识符转换为HKObjectType,这是初始化程序的预期参数类型。