Skip to content

Instantly share code, notes, and snippets.

@ateliercw
ateliercw / curried_deselect.swift
Last active June 10, 2016 20:11
Comparing a curried and un-curried deselect rows function
extension UIViewController {
func rz_smoothlyDeselectRows(tableView tableViewIn: UITableView?) {
guard let tableView = tableViewIn,
selectedIndexPaths = tableView.indexPathsForSelectedRows else {
return
}
let deselect = { (tableView: UITableView, animated: Bool) -> ((NSIndexPath) -> ()) in
@ateliercw
ateliercw / swiftilities_deselect.swift
Last active June 10, 2016 03:44
An un-curried deselect function, for comparison with curried_deselect
extension UIViewController {
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) {
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? []
if let coordinator = transitionCoordinator() {
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in
selectedIndexPaths.forEach {
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated())
}