add delete and insert methods

This commit is contained in:
Max Sokolov 2016-06-15 20:56:17 +03:00
parent d01c6c7fba
commit 1bd049e276
2 changed files with 9 additions and 42 deletions

View File

@ -46,52 +46,11 @@ class MainController: UIViewController {
.addAction(TableRowAction(.click) { (data) in
print("2")
})
let section = TableSection()
section.append(builder: b)
//let section = TableSection(headerTitle: "", footerTitle: "", rows: [row1, row2, row3])
tableDirector += [section]
//tableDirector.append(section: section)
/*rowBuilder
.addAction(TableRowAction(type: .Click) { (data) in
})
rowBuilder
.delete(indexes: [0], animated: .None)
.insert(["2"], atIndex: 0, animated: .None)
.update(index: 0, item: "", animated: .None)
.move([1, 2], toIndexes: [3, 4])
//tableView.moveRowAtIndexPath(<#T##indexPath: NSIndexPath##NSIndexPath#>, toIndexPath: <#T##NSIndexPath#>)
//tableView.deleteRowsAtIndexPaths(<#T##indexPaths: [NSIndexPath]##[NSIndexPath]#>, withRowAnimation: <#T##UITableViewRowAnimation#>)
//tableView.insertRowsAtIndexPaths(<#T##indexPaths: [NSIndexPath]##[NSIndexPath]#>, withRowAnimation: <#T##UITableViewRowAnimation#>)
//tableView.reloadRowsAtIndexPaths(<#T##indexPaths: [NSIndexPath]##[NSIndexPath]#>, withRowAnimation: <#T##UITableViewRowAnimation#>)
//tableView.moveSection(0, toSection: 0)
//tableView.reloadSections([], withRowAnimation: .None)
//tableView.deleteSections([], withRowAnimation: .None)
//tableView.insertSections([], withRowAnimation: .None)
//tableDirector.performBatchUpdates {
//}*/
//tableDirector.append(section: section)
}
}

View File

@ -66,8 +66,16 @@ public class TableSection {
public func append(row row: Row) {
append(rows: [row])
}
public func append(rows rows: [Row]) {
items.appendContentsOf(rows)
}
public func insert(row row: Row, atIndex index: Int) {
items.insert(row, atIndex: index)
}
public func delete(index: Int) {
items.removeAtIndex(index)
}
}