我正在尝试创建一个条件语句,该条件语句根据tableView是否具有任何选中标记附件来做事。
当前,我有以下代码检查是否选中了记录,但是我想检查tableView的任何行中是否存在选中标记附件,是否可以验证类似的东西?
查看是否已选择行的代码:
if structure.isEmpty ||
(tableView.indexPathsForSelectedRows != nil &&
!tableView.indexPathsForSelectedRows!.isEmpty) {
//Do this...
} else {
//Do this...
}
structure
被定义为var structure = [JSONStructure]()
JSONStructure是填充tableView的JSON数据的结构。
答案 0 :(得分:0)
我建议您添加一个数组,该数组跟踪带有复选标记附件的行,因此,当您添加复选标记时,也应将该行的indexPath添加到该数组中,并且在删除复选标记时也应如此
let checkedCells = [IndexPath]()
现在您可以添加这样的语句
if structure.isEmpty || !checkedCells.isEmpty {
//Do this...
} else {
//Do this...
}