我目前正在swift中开发一个基于ResearchKit框架(用objective-c编写)的医学研究应用程序。我正在尝试创建一个带有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)”的参数列表

最佳答案

您需要将标识符转换为HKObjectType,它是初始值设定项的预期参数类型。

关于ios - Swift ResearchKit HealthKit QuestionStep,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31214072/

10-08 20:33