Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collection and table view sugars #26

Merged
merged 5 commits into from
Jan 5, 2016
Merged

Conversation

zenangst
Copy link
Contributor

@zenangst zenangst commented Jan 5, 2016

This PR adds some sugars for inserting, updating and deleting indexes on a UITableView or UICollectionView.

public extension UICollectionView {
  func insert(indexes: [Int], section: Int = 0, completion: (() -> Void)? = nil) {}
  func reload(indexes: [Int], section: Int = 0, completion: (() -> Void)? = nil) {}
  func remove(indexes: [Int], section: Int = 0, completion: (() -> Void)? = nil) {}
  func reloadSection(index: Int = 0, completion: (() -> Void)? = nil) {}
}

public extension UITableView {

  func insert(indexes: [Int], section: Int = 0, animation: UITableViewRowAnimation = .None) {}
  func reload(indexes: [Int], section: Int = 0, animation: UITableViewRowAnimation = .None) {}
  func remove(indexes: [Int], section: Int = 0, animation: UITableViewRowAnimation = .None) {}
  func reloadSection(section: Int = 0, animation: UITableViewRowAnimation = .None) {}
  private func performUpdates(@noescape closure: () -> Void) {}
}

If you only have one section and no completion you could just run;

tableView.insert([1,2,3])

@vadymmarkov
Copy link
Contributor

@zenangst Nice!

vadymmarkov added a commit that referenced this pull request Jan 5, 2016
Add collection and table view sugars
@vadymmarkov vadymmarkov merged commit bb8e269 into master Jan 5, 2016
@vadymmarkov vadymmarkov deleted the add/collection-sugar branch January 5, 2016 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants