首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ResearchKit代码出现“使用无法解析的标识符”错误

ResearchKit代码出现“使用无法解析的标识符”错误
EN

Stack Overflow用户
提问于 2018-06-13 03:02:59
回答 1查看 1.4K关注 0票数 1

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

代码语言:javascript
运行
复制
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。这似乎是一个特定于案例的问题,因为对其他问题的回答在这种情况下没有帮助。

EN

回答 1

Stack Overflow用户

发布于 2018-06-13 03:07:58

替换这个

代码语言:javascript
运行
复制
let _: [ORKConsentSectionType] = [
  .Overview,
  .DataGathering,
  .Privacy,
  .DataUse,
  .TimeCommitment,
  .StudySurvey,
  .StudyTasks,
  .Withdrawing
]

使用

代码语言:javascript
运行
复制
let consentSectionType: [ORKConsentSectionType] = [
  .Overview,
  .DataGathering,
  .Privacy,
  .DataUse,
  .TimeCommitment,
  .StudySurvey,
  .StudyTasks,
  .Withdrawing
]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50824127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档