0
我正在处理表单。包含多个单元格的表格供用户选择选项。每个单元格都有一个标签作为问题,一个选择器视图带有选项作为答案。在我点击下一步按钮之前,如何获取单元格的所有值?选取器视图的数据源是一个列表。我想得到的值是选择器视图选项的索引。由于 swift获取tableview单元格的所有值
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = myTable.dequeueReusableCellWithIdentifier("addFollowCell", forIndexPath: indexPath) as! AddFollowTableViewCell
cell.questionView.text = listQuestion1[indexPath.row]
cell.pickerDataSource = dictPicker[indexPath.row]!
return cell
}
func getData()->[Int]{
}
func getCellsData() -> [Int] {
var dataArray: [Int] = []
for section in 0 ..< self.myTable.numberOfSections {
for row in 0 ..< self.myTable.numberOfRowsInSection(section) {
let indexPath = NSIndexPath(forRow: row, inSection: section)
let cell = self.myTable.cellForRowAtIndexPath(indexPath) as! AddFollowTableViewCell
dataArray.append(cell.cellValue)
}
}
return dataArray
}
func getCellsData()给我一个错误的致命错误:意外地发现零,而它运行到第五行时展开一个可选值。该表共有7行 –