ios - Swift ResearchKit HealthKit QuestionStep

标签 ios swift healthkit researchkit

我目前正在基于 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/

相关文章:

ios - 使用 Objective-C 创建 iOS 框架

ios - 如何使用 Apple HealthKit 获得每日 sleep 时长?

ios - 尝试给我们 UIAlertController 打分

ios - 如何识别 ionic 和 ios 上的 401 和 408(超时)错误?

iOS9 不会从安全页面(SSL/HTTPS)加载不安全的资源

ios - 使用 swift 4 以编程方式注册时自定义单元格未显示

Swift5(+RxSwift) 'self' 在所有成员初始化之前被闭包捕获

ios - 如何使用完成处理程序正确关闭模态视图 Controller

swift - "An error occurred with the ` 事件能源查询 `. The error was: Authorization not determined."

ios - 具有累积聚合样式的 HKQuantityType 月份的统计信息