使用ResearchKit代码“使用未解析的标识符”错误

时间:2018-06-12 19:02:59

标签: swift researchkit xcode9.4

我正在使用ResearchKit通过Ray Wenderlich教程构建一个应用程序,以下代码继续给出错误消息:Use of unresolved identifier 'consentSectionType'这是当前的错误消息。由于我没有编写代码,我不确定它有什么问题,我不知道如何修复它。这是代码:

public var ConsentDocument: ORKConsentDocument {

let consentDocument = ORKConsentDocument()
consentDocument.title = "Consent"

let _: [ORKConsentSectionType] = [
    .overview,
    .dataGathering,
    .privacy,
    .dataUse,
    .timeCommitment,
    .studySurvey,
    .studyTasks,
    .withdrawing
]
var consentSections: [ORKConsentSection] = consentSectionType.map { contentSectionType in
    let consentSection = ORKConsentSection(type: contentSectionType)
    consentSection.summary = "x."
    consentSection.content = "y."
    return consentSection
}

consentDocument.sections = consentSections

有时,Xcode会建议我将consentSectionType.map更改为ORKConsentSection.map,但这只会带来另一条显示Type 'ORKConsentSection.map' has no member map的错误消息。这似乎是一个案例特定的问题,因为在这种情况下,其他问题的答案没有帮助。

1 个答案:

答案 0 :(得分:1)

替换此

let _: [ORKConsentSectionType] = [
  .Overview,
  .DataGathering,
  .Privacy,
  .DataUse,
  .TimeCommitment,
  .StudySurvey,
  .StudyTasks,
  .Withdrawing
]

let consentSectionType: [ORKConsentSectionType] = [
  .Overview,
  .DataGathering,
  .Privacy,
  .DataUse,
  .TimeCommitment,
  .StudySurvey,
  .StudyTasks,
  .Withdrawing
]