我正在使用 Alamofire 库进行 http 请求。
我知道如何在纯文本字段中循环:
for option in json["options"] {
let opts = json["options"]["is_selected"].string
if json["options"][ctr]["is_selected"] == 1 {
if json["options"][ctr]["id"] == "8" {
self.emailSwitch.on = true
self.unameSwitch.on = true
}
}
println(json["options"][ctr]["id"])
ctr++
}
但是如何在 TableView 中执行此操作?
最佳答案
您可以像这样迭代 uitableview:
for section in 0..<tableView.numberOfSections() {
for row in 0..<tableView.numberOfRowsInSection(section) {
let indexPath = NSIndexPath(forRow: row, inSection: section)
var cell = tableView.cellForRowAtIndexPath(indexPath)
// do what you want with the cell
}
}
关于ios - 如何在 Swift 中循环访问 UITableView 中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29601294/