我目前正在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]
然而,第一行导致错误:
找不到接受类型为"(characteristicType:String("的参数列表的"ORKHealthKitCharacteristicTypeAnswerFormat"的初始值设定项
您需要将标识符转换为HKObjectType,这是初始值设定项的预期参数类型。