【发布时间】:2016-10-07 10:31:23
【问题描述】:
我是 Swift 新手,正在尝试一些教程来学习和完善我对 Swift 的了解。我在这段代码中偶然发现了我不理解的上述错误。如果你们中的任何人有想法,请在此处解释问题所在。
let textChoices = [
ORKTextChoice(text: "Create a ResearchKit app", value:0),
ORKTextChoice(text: "Seek the Holy grail", value:1),
ORKTextChoice(text: "Find a shrubbery", value:2)
]
我通过 Xcode 提供的建议解决了错误,现在我的代码看起来像
let textChoices = [
ORKTextChoice(text: "Create a ResearchKit app", value:0 as NSCoding & NSCopying & NSObjectProtocol),
ORKTextChoice(text: "Seek the Holy grail", value:1 as NSCoding & NSCopying & NSObjectProtocol),
ORKTextChoice(text: "Find a shrubbery", value:2 as NSCoding & NSCopying & NSObjectProtocol)
]
我从answer 得到了另一个解决方案。虽然它有效,但我仍然不清楚问题和解决方案。我缺少什么概念。
【问题讨论】:
标签: swift researchkit