我目前正在基于 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]
但是,第一行会导致错误:
找不到接受类型为“(characteristicType: String)”的参数列表的“ORKHealthKitCharacteristicTypeAnswerFormat”的初始值设定项
最佳答案
您需要将标识符转换为 HKObjectType,这是初始化程序的预期参数类型。
关于ios - Swift ResearchKit HealthKit QuestionStep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31214072/