【发布时间】:2015-12-27 19:36:35
【问题描述】:
我有一个 TableView,从中我得到一个数组中选定的 tableViewCell's 值,但它不是所需的数组:
[<NSIndexPath: 0xc000000000200016\> {length = 2, path = 0 - 1}: "test1234", <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}: "Judson"]
如何过滤得到["test1234","Judson"]?
这是我正在使用的代码:
var selectedTextLabels = [NSIndexPath: String]()
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
let cell = tableView.cellForRowAtIndexPath(indexPath) as! UsersTableViewCell
if (cell.accessoryType == UITableViewCellAccessoryType.Checkmark){
cell.accessoryType = UITableViewCellAccessoryType.None;
selectedTextLabels[indexPath] = nil
} else {
cell.accessoryType = UITableViewCellAccessoryType.Checkmark;
if (cell.accessoryType == UITableViewCellAccessoryType.Checkmark){
if let text = cell.collegeNameLbl?.text {
selectedTextLabels[indexPath] = text
}
}
}
print("\(selectedTextLabels) outside")
}
【问题讨论】:
标签: ios arrays swift uitableview