已针对新问题进行了编辑:类型为“ QuestionController”的实例成员“ questionsList”不能在嵌套类型为“ QuestionController.QuestionController”的实例上使用
有人可以解释快速解决方案吗?我仍在学习Swift,所以不太清楚它要我做什么。
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let index = navigationController?.viewControllers.indexOf()->() {
let question = questionsList[index]
if let count = question.answers?.count {
return count
}
}
return 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath as IndexPath) as! AnswerCell
if let index = navigationController?.viewControllers.indexOf() {
let question = questionsList[index]
cell.nameLabel.text = question.answers?[indexPath.row]
}
Run Code Online (Sandbox Code Playgroud)
新问题:
错误首先出现在第47行:
import UIKit
struct Question { …Run Code Online (Sandbox Code Playgroud)