Ошибка «Использование неразрешенного идентификатора» с кодом ResearchKit - PullRequest
0 голосов
/ 12 июня 2018

Я создаю приложение с помощью 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 голосов
/ 12 июня 2018

Замените это

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

на

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