我正在通过 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.map
更改为ORKConsentSection.map
,但这只会带来另一个错误消息,说Type 'ORKConsentSection.map' has no member map
。这似乎是一个特定于案例的问题,因为在这种情况下,其他问题的答案没有帮助。
替换这个
let _: [ORKConsentSectionType] = [
.Overview,
.DataGathering,
.Privacy,
.DataUse,
.TimeCommitment,
.StudySurvey,
.StudyTasks,
.Withdrawing
]
跟
let consentSectionType: [ORKConsentSectionType] = [
.Overview,
.DataGathering,
.Privacy,
.DataUse,
.TimeCommitment,
.StudySurvey,
.StudyTasks,
.Withdrawing
]