1

我正在通过 Ray Wenderlich 教程使用 ResearchKit 构建一个应用程序,以下代码继续给出错误消息: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.mapORKConsentSection.map,但这只会带来另一条错误消息,上面写着Type 'ORKConsentSection.map' has no member map. 这似乎是一个特定于案例的问题,因为在这种情况下对其他问题的回答没有帮助。

4

1 回答 1

1

替换这个

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

let consentSectionType: [ORKConsentSectionType] = [
  .Overview,
  .DataGathering,
  .Privacy,
  .DataUse,
  .TimeCommitment,
  .StudySurvey,
  .StudyTasks,
  .Withdrawing
]
于 2018-06-12T19:07:57.980 回答