     super.layoutSubviews()
     tableView.frame = bounds
     staticContentView.frame = bounds
-  }
-}
-
-// MARK: - UITableView bridge
-extension StatefulTableView {
-  /// Bridge for UITableivew methods. Read UITableView documentation for more details
-
-  /// Data
-
-  /// Info
-
-  /// Row insertion/deletion/reloading
-
-  /// Editing. When set, rows show insert/delete/reorder control based on data source queries
-
-  /// Selection
-
-  /// Appearance
-
-  /// Beginning in iOS 6, clients can register a nib or class for each cell.
-  /// If all reuse identifiers are registered, use the newer -dequeueReusableCellWithIdentifier:forIndexPath: to guarantee that a cell instance is returned.
-  /// Instances returned from the new dequeue method will also be properly sized when they are returned.
-
-  /// Focus
-
-}
-
-// MARK: - Configuring a Table View
-extension StatefulTableView {
-  public func numberOfRowsInSection(section: Int) -> Int {
-    return tableView.numberOfRowsInSection(section)
-  }
-
-  public var numberOfSections: Int {
-    return tableView.numberOfSections
-  }
-
-  /**
-   The height of each row (that is, table cell) in the table view.
-
-   - Discussion: Visit this [link](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instp/UITableView/rowHeight) for more details
-   */
-  public var rowHeight: CGFloat {
-    set { tableView.rowHeight = newValue }
-    get { return tableView.rowHeight }
-  }
-
-  public var separatorStyle: UITableViewCellSeparatorStyle {
-    set { tableView.separatorStyle = newValue }
-    get { return tableView.separatorStyle }
-  }
-
-  public var separatorColor: UIColor? {
-    set { tableView.separatorColor = newValue }
-    get { return tableView.separatorColor }
-  }
-
-  @available(iOS 8.0, *)
-  public var separatorEffect: UIVisualEffect? {
-    set { tableView.separatorEffect = newValue }
-    get { return tableView.separatorEffect }
-  }
-
-  @available(iOS 7.0, *)
-  public var separatorInset: UIEdgeInsets {
-    set { tableView.separatorInset = newValue }
-    get { return tableView.separatorInset }
-  }
-
-  @available(iOS 9.0, *)
-  public var cellLayoutMarginsFollowReadableWidth: Bool {
-    set { tableView.cellLayoutMarginsFollowReadableWidth = newValue }
-    get { return tableView.cellLayoutMarginsFollowReadableWidth }
-  }
-}
-
-// MARK: - Creating Table View Cells
-extension StatefulTableView {
-  @available(iOS 5.0, *)
-  public func registerNib(nib: UINib?, forCellReuseIdentifier identifier: String) {
-    tableView.registerNib(nib, forCellReuseIdentifier: identifier)
-  }
-
-  @available(iOS 6.0, *)
-  public func registerClass(cellClass: AnyClass?, forCellReuseIdentifier identifier: String) {
-    tableView.registerClass(cellClass, forCellReuseIdentifier: identifier)
-  }
-
-  @available(iOS 6.0, *)
-  public func dequeueReusableCellWithIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath) -> UITableViewCell {
-    return tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath)
-  }
-
-  public func dequeueReusableCellWithIdentifier(identifier: String) -> UITableViewCell? {
-    return tableView.dequeueReusableCellWithIdentifier(identifier)
-  }
-}
-
-// MARK: - Accessing Header and Footer Views
-extension StatefulTableView {
-  @available(iOS 6.0, *)
-  public func registerNib(nib: UINib?, forHeaderFooterViewReuseIdentifier identifier: String) {
-    tableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: identifier)
-  }
-
-  @available(iOS 6.0, *)
-  public func registerClass(aClass: AnyClass?, forHeaderFooterViewReuseIdentifier identifier: String) {
-    tableView.registerClass(aClass, forHeaderFooterViewReuseIdentifier: identifier)
-  }
-
-  @available(iOS 6.0, *)
-  public func dequeueReusableHeaderFooterViewWithIdentifier(identifier: String) -> UITableViewHeaderFooterView? {
-    return tableView.dequeueReusableHeaderFooterViewWithIdentifier(identifier)
-  }
-
-  public var tableHeaderView: UIView? {
-    set { tableView.tableHeaderView = newValue }
-    get { return tableView.tableHeaderView }
-  }
-
-  public var tableFooterView: UIView? {
-    set { tableView.tableFooterView = newValue }
-    get { return tableView.tableFooterView }
-  }
-
-  public var sectionHeaderHeight: CGFloat {
-    set { tableView.sectionHeaderHeight = newValue }
-    get { return tableView.sectionHeaderHeight }
-  }
-
-  public var sectionFooterHeight: CGFloat {
-    set { tableView.sectionFooterHeight = newValue }
-    get { return tableView.sectionFooterHeight }
-  }
-
-  @available(iOS 6.0, *)
-  public func headerViewForSection(section: Int) -> UITableViewHeaderFooterView? {
-    return tableView.headerViewForSection(section)
-  }
-
-  @available(iOS 6.0, *)
-  public func footerViewForSection(section: Int) -> UITableViewHeaderFooterView? {
-    return tableView.footerViewForSection(section)
-  }
-}
-
-// MARK: - Accessing Cells and Sections
-extension StatefulTableView {
-  public func cellForRowAtIndexPath(indexPath: NSIndexPath) -> UITableViewCell? {
-    return tableView.cellForRowAtIndexPath(indexPath)
-  }
-
-  public func indexPathForCell(cell: UITableViewCell) -> NSIndexPath? {
-    return tableView.indexPathForCell(cell)
-  }
-
-  public func indexPathForRowAtPoint(point: CGPoint) -> NSIndexPath? {
-    return tableView.indexPathForRowAtPoint(point)
-  }
-
-  public func indexPathsForRowsInRect(rect: CGRect) -> [NSIndexPath]? {
-    return tableView.indexPathsForRowsInRect(rect)
-  }
-
-  public var visibleCells: [UITableViewCell] {
-    return tableView.visibleCells
-  }
-
-  public var indexPathsForVisibleRows: [NSIndexPath]? {
-    return tableView.indexPathsForVisibleRows;
-  }
-}
-
-// MARK: - Estimating Element Heights
-extension StatefulTableView {
-  @available(iOS 7.0, *)
-  public var estimatedRowHeight: CGFloat {
-    set { tableView.estimatedRowHeight = newValue }
-    get { return tableView.estimatedRowHeight }
-  }
-
-  @available(iOS 7.0, *)
-  public var estimatedSectionHeaderHeight: CGFloat {
-    set { tableView.estimatedSectionHeaderHeight = newValue }
-    get { return tableView.estimatedSectionHeaderHeight }
-  }
-
-  @available(iOS 7.0, *)
-  public var estimatedSectionFooterHeight: CGFloat {
-    set { tableView.estimatedSectionFooterHeight = newValue }
-    get { return tableView.estimatedSectionHeaderHeight }
-  }
-}
-
-// MARK: - Scrolling the Table View
-extension StatefulTableView {
-  public func scrollToRowAtIndexPath(indexPath: NSIndexPath, atScrollPosition scrollPosition: UITableViewScrollPosition, animated: Bool) {
-    tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: scrollPosition, animated: animated)
-  }
-
-  public func scrollToNearestSelectedRowAtScrollPosition(scrollPosition: UITableViewScrollPosition, animated: Bool) {
-    tableView.scrollToNearestSelectedRowAtScrollPosition(scrollPosition, animated: animated)
-  }
-}
-
-// MARK: - Managing Selections
-extension StatefulTableView {
-  public var indexPathForSelectedRow: NSIndexPath? {
-    return tableView.indexPathForSelectedRow
-  }
-
-  @available(iOS 5.0, *)
-  public var indexPathsForSelectedRows: [NSIndexPath]? {
-    return tableView.indexPathsForSelectedRows
-  }
-
-  public func selectRowAtIndexPath(indexPath: NSIndexPath?, animated: Bool, scrollPosition: UITableViewScrollPosition) {
-    tableView.selectRowAtIndexPath(indexPath, animated: animated, scrollPosition: scrollPosition)
-  }
-
-  public func deselectRowAtIndexPath(indexPath: NSIndexPath, animated: Bool) {
-    tableView.deselectRowAtIndexPath(indexPath, animated: animated)
-  }
-
-  @available(iOS 3.0, *)
-  public var allowsSelection: Bool {
-    set { tableView.allowsSelection = newValue }
-    get { return tableView.allowsSelection }
-  }
-
-  @available(iOS 5.0, *)
-  public var allowsMultipleSelection: Bool {
-    set { tableView.allowsMultipleSelection = newValue }
-    get { return tableView.allowsMultipleSelection }
-  }
-
-  public var allowsSelectionDuringEditing: Bool {
-    set { tableView.allowsSelectionDuringEditing = newValue }
-    get { return tableView.allowsSelectionDuringEditing }
-  }
-
-  @available(iOS 5.0, *)
-  public var allowsMultipleSelectionDuringEditing: Bool {
-    set { tableView.allowsMultipleSelectionDuringEditing = newValue }
-    get { return tableView.allowsMultipleSelectionDuringEditing }
-  }
-}
-
-// MARK: - Inserting, Deleting, and Moving Rows and Sections
-extension StatefulTableView {
-  public func beginUpdates() {
-    tableView.beginUpdates()
-  }
-
-  public func endUpdates() {
-    tableView.endUpdates()
-  }
-
-  public func insertRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
-  }
-
-  public func deleteRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
-  }
-
-  @available(iOS 5.0, *)
-  public func moveRowAtIndexPath(indexPath: NSIndexPath, toIndexPath newIndexPath: NSIndexPath) {
-    tableView.moveRowAtIndexPath(indexPath, toIndexPath: newIndexPath)
-  }
-
-  public func insertSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.insertSections(sections, withRowAnimation: animation)
-  }
-
-  public func deleteSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.deleteSections(sections, withRowAnimation: animation)
-  }
-
-  @available(iOS 5.0, *)
-  public func moveSection(section: Int, toSection newSection: Int) {
-    tableView.moveSection(section, toSection: newSection)
-  }
-}
-
-// MARK: - Managing the Editing of Table Cells
-extension StatefulTableView {
-  public var editing: Bool {
-    set { tableView.editing = newValue }
-    get { return tableView.editing }
-  }
-
-  public func setEditing(editing: Bool, animated: Bool) {
-    tableView.setEditing(editing, animated: animated)
-  }
-}
-
-// MARK: - Reloading the Table View
-extension StatefulTableView {
-  public func reloadData() {
-    dispatch_async(dispatch_get_main_queue()) {
-      self.tableView.reloadData()
-    }
-  }
-
-  @available(iOS 3.0, *)
-  public func reloadRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.reloadRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
-  }
-
-  @available(iOS 3.0, *)
-  public func reloadSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
-    tableView.reloadSections(sections, withRowAnimation: animation)
-  }
-
-  @available(iOS 3.0, *)
-  public func reloadSectionIndexTitles() {
-    dispatch_async(dispatch_get_main_queue()) {
-      self.tableView.reloadSectionIndexTitles()
-    }
-  }
-}
-
-// MARK: - Accessing Drawing Areas of the Table View
-extension StatefulTableView {
-  public func rectForSection(section: Int) -> CGRect {
-    return tableView.rectForSection(section)
-  }
-
-  public func rectForRowRowAtIndexPath(indexPath: NSIndexPath) -> CGRect {
-    return tableView.rectForRowAtIndexPath(indexPath)
-  }
-
-  public func rectForFooterInSection(section: Int) -> CGRect {
-    return tableView.rectForFooterInSection(section)
-  }
-
-  public func rectFotHeaderInSection(section: Int) -> CGRect {
-    return tableView.rectForHeaderInSection(section)
-  }
-}
-
-// MARK: - Managing the Delegate and the Data Source
-extension StatefulTableView {
-  /**
-   The object that acts as the data source of the table view.
-
-   - Discussion: The data souce must adopt the `UITableViewDataSource` protocol. The data source is not retained.
-   */
-  public var dataSource: UITableViewDataSource? {
-    set { tableView.dataSource = newValue }
-    get { return tableView.dataSource }
-  }
-
-  /**
-   The object that acts as the delegate of the table view.
-
-   - Discussion: The delegate must adopt the `UITableViewDelegate` protocol. The delegate is not retained.
-   */
-  public var delegate: UITableViewDelegate? {
-    set { tableView.delegate = newValue }
-    get { return tableView.delegate }
-  }
-}
-
-// MARK: - Configuring the Table Index
-extension StatefulTableView {
-  public var sectionIndexMinimumDisplayRowCount: Int {
-    set { tableView.sectionIndexMinimumDisplayRowCount = newValue }
-    get { return tableView.sectionIndexMinimumDisplayRowCount }
-  }
-
-  @available(iOS 6.0, *)
-  public var sectionIndexColor: UIColor? {
-    set { tableView.sectionIndexColor = newValue }
-    get { return tableView.sectionIndexColor }
-  }
-
-  @available(iOS 7.0, *)
-  public var sectionIndexBackgroundColor: UIColor? {
-    set { tableView.sectionIndexBackgroundColor = newValue }
-    get { return tableView.sectionIndexBackgroundColor }
-  }
-
-  @available(iOS 6.0, *)
-  public var sectionIndexTrackingBackgroundColor: UIColor? {
-    set { tableView.sectionIndexTrackingBackgroundColor = newValue }
-    get { return tableView.sectionIndexTrackingBackgroundColor }
-  }
-}
-
-// MARK: - Managing Focus
-extension StatefulTableView {
-  @available(iOS 9.0, *)
-  public var remembersLastFocusedIndexPath: Bool {
-    set { tableView.remembersLastFocusedIndexPath = newValue }
-    get { return tableView.remembersLastFocusedIndexPath }
   }
 }
 

  }
}

extension UIView {
  func setWidthConstraintToCurrent() {
    setWidthConstraint(bounds.width)
  }

  func setHeightConstraintToCurrent() {
    setHeightConstraint(bounds.height)
  }

  func setWidthConstraint(width: CGFloat) {
    addConstraint(NSLayoutConstraint(item: self, attribute: .Width, relatedBy: .Equal, toItem: nil,
      attribute: .NotAnAttribute, multiplier: 1, constant: width))
  }

  func setHeightConstraint(height: CGFloat) {
    addConstraint(NSLayoutConstraint(item: self, attribute: .Height, relatedBy: .Equal, toItem: nil,
      attribute: .NotAnAttribute, multiplier: 1, constant: height))
  }

  }
}

// MARK: - Configuring a Table View
extension StatefulTableView {
  public func numberOfRowsInSection(section: Int) -> Int {
    return tableView.numberOfRowsInSection(section)
  }

  public var numberOfSections: Int {
    return tableView.numberOfSections
  }

  /**
   The height of each row (that is, table cell) in the table view.

   - Discussion: Visit this [link](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instp/UITableView/rowHeight) for more details
   */
  public var rowHeight: CGFloat {
    set { tableView.rowHeight = newValue }
    get { return tableView.rowHeight }
  }

  public var separatorStyle: UITableViewCellSeparatorStyle {
    set { tableView.separatorStyle = newValue }
    get { return tableView.separatorStyle }
  }

  public var separatorColor: UIColor? {
    set { tableView.separatorColor = newValue }
    get { return tableView.separatorColor }
  }

  @available(iOS 8.0, *)
  public var separatorEffect: UIVisualEffect? {
    set { tableView.separatorEffect = newValue }
    get { return tableView.separatorEffect }
  }

  @available(iOS 7.0, *)
  public var separatorInset: UIEdgeInsets {
    set { tableView.separatorInset = newValue }
    get { return tableView.separatorInset }
  }

  @available(iOS 9.0, *)
  public var cellLayoutMarginsFollowReadableWidth: Bool {
    set { tableView.cellLayoutMarginsFollowReadableWidth = newValue }
    get { return tableView.cellLayoutMarginsFollowReadableWidth }
  }
}

// MARK: - Creating Table View Cells
extension StatefulTableView {
  @available(iOS 5.0, *)
  public func registerNib(nib: UINib?, forCellReuseIdentifier identifier: String) {
    tableView.registerNib(nib, forCellReuseIdentifier: identifier)
  }

  @available(iOS 6.0, *)
  public func registerClass(cellClass: AnyClass?, forCellReuseIdentifier identifier: String) {
    tableView.registerClass(cellClass, forCellReuseIdentifier: identifier)
  }

  @available(iOS 6.0, *)
  public func dequeueReusableCellWithIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    return tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath)
  }

  public func dequeueReusableCellWithIdentifier(identifier: String) -> UITableViewCell? {
    return tableView.dequeueReusableCellWithIdentifier(identifier)
  }
}

// MARK: - Accessing Header and Footer Views
extension StatefulTableView {
  @available(iOS 6.0, *)
  public func registerNib(nib: UINib?, forHeaderFooterViewReuseIdentifier identifier: String) {
    tableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: identifier)
  }

  @available(iOS 6.0, *)
  public func registerClass(aClass: AnyClass?, forHeaderFooterViewReuseIdentifier identifier: String) {
    tableView.registerClass(aClass, forHeaderFooterViewReuseIdentifier: identifier)
  }

  @available(iOS 6.0, *)
  public func dequeueReusableHeaderFooterViewWithIdentifier(identifier: String) -> UITableViewHeaderFooterView? {
    return tableView.dequeueReusableHeaderFooterViewWithIdentifier(identifier)
  }

  public var tableHeaderView: UIView? {
    set { tableView.tableHeaderView = newValue }
    get { return tableView.tableHeaderView }
  }

  public var tableFooterView: UIView? {
    set { tableView.tableFooterView = newValue }
    get { return tableView.tableFooterView }
  }

  public var sectionHeaderHeight: CGFloat {
    set { tableView.sectionHeaderHeight = newValue }
    get { return tableView.sectionHeaderHeight }
  }

  public var sectionFooterHeight: CGFloat {
    set { tableView.sectionFooterHeight = newValue }
    get { return tableView.sectionFooterHeight }
  }

  @available(iOS 6.0, *)
  public func headerViewForSection(section: Int) -> UITableViewHeaderFooterView? {
    return tableView.headerViewForSection(section)
  }

  @available(iOS 6.0, *)
  public func footerViewForSection(section: Int) -> UITableViewHeaderFooterView? {
    return tableView.footerViewForSection(section)
  }
}

// MARK: - Accessing Cells and Sections
extension StatefulTableView {
  public func cellForRowAtIndexPath(indexPath: NSIndexPath) -> UITableViewCell? {
    return tableView.cellForRowAtIndexPath(indexPath)
  }

  public func indexPathForCell(cell: UITableViewCell) -> NSIndexPath? {
    return tableView.indexPathForCell(cell)
  }

  public func indexPathForRowAtPoint(point: CGPoint) -> NSIndexPath? {
    return tableView.indexPathForRowAtPoint(point)
  }

  public func indexPathsForRowsInRect(rect: CGRect) -> [NSIndexPath]? {
    return tableView.indexPathsForRowsInRect(rect)
  }

  public var visibleCells: [UITableViewCell] {
    return tableView.visibleCells
  }

  public var indexPathsForVisibleRows: [NSIndexPath]? {
    return tableView.indexPathsForVisibleRows;
  }
}

// MARK: - Estimating Element Heights
extension StatefulTableView {
  @available(iOS 7.0, *)
  public var estimatedRowHeight: CGFloat {
    set { tableView.estimatedRowHeight = newValue }
    get { return tableView.estimatedRowHeight }
  }

  @available(iOS 7.0, *)
  public var estimatedSectionHeaderHeight: CGFloat {
    set { tableView.estimatedSectionHeaderHeight = newValue }
    get { return tableView.estimatedSectionHeaderHeight }
  }

  @available(iOS 7.0, *)
  public var estimatedSectionFooterHeight: CGFloat {
    set { tableView.estimatedSectionFooterHeight = newValue }
    get { return tableView.estimatedSectionHeaderHeight }
  }
}

// MARK: - Scrolling the Table View
extension StatefulTableView {
  public func scrollToRowAtIndexPath(indexPath: NSIndexPath, atScrollPosition scrollPosition: UITableViewScrollPosition, animated: Bool) {
    tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: scrollPosition, animated: animated)
  }

  public func scrollToNearestSelectedRowAtScrollPosition(scrollPosition: UITableViewScrollPosition, animated: Bool) {
    tableView.scrollToNearestSelectedRowAtScrollPosition(scrollPosition, animated: animated)
  }
}

// MARK: - Managing Selections
extension StatefulTableView {
  public var indexPathForSelectedRow: NSIndexPath? {
    return tableView.indexPathForSelectedRow
  }

  @available(iOS 5.0, *)
  public var indexPathsForSelectedRows: [NSIndexPath]? {
    return tableView.indexPathsForSelectedRows
  }

  public func selectRowAtIndexPath(indexPath: NSIndexPath?, animated: Bool, scrollPosition: UITableViewScrollPosition) {
    tableView.selectRowAtIndexPath(indexPath, animated: animated, scrollPosition: scrollPosition)
  }

  public func deselectRowAtIndexPath(indexPath: NSIndexPath, animated: Bool) {
    tableView.deselectRowAtIndexPath(indexPath, animated: animated)
  }

  @available(iOS 3.0, *)
  public var allowsSelection: Bool {
    set { tableView.allowsSelection = newValue }
    get { return tableView.allowsSelection }
  }

  @available(iOS 5.0, *)
  public var allowsMultipleSelection: Bool {
    set { tableView.allowsMultipleSelection = newValue }
    get { return tableView.allowsMultipleSelection }
  }

  public var allowsSelectionDuringEditing: Bool {
    set { tableView.allowsSelectionDuringEditing = newValue }
    get { return tableView.allowsSelectionDuringEditing }
  }

  @available(iOS 5.0, *)
  public var allowsMultipleSelectionDuringEditing: Bool {
    set { tableView.allowsMultipleSelectionDuringEditing = newValue }
    get { return tableView.allowsMultipleSelectionDuringEditing }
  }
}

// MARK: - Inserting, Deleting, and Moving Rows and Sections
extension StatefulTableView {
  public func beginUpdates() {
    tableView.beginUpdates()
  }

  public func endUpdates() {
    tableView.endUpdates()
  }

  public func insertRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
    tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
  }

  public func deleteRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
    tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
  }

  @available(iOS 5.0, *)
  public func moveRowAtIndexPath(indexPath: NSIndexPath, toIndexPath newIndexPath: NSIndexPath) {
    tableView.moveRowAtIndexPath(indexPath, toIndexPath: newIndexPath)
  }

  public func insertSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
    tableView.insertSections(sections, withRowAnimation: animation)
  }

  public func deleteSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
    tableView.deleteSections(sections, withRowAnimation: animation)
  }

  @available(iOS 5.0, *)
  public func moveSection(section: Int, toSection newSection: Int) {
    tableView.moveSection(section, toSection: newSection)
  }
}

// MARK: - Managing the Editing of Table Cells
extension StatefulTableView {
  public var editing: Bool {
    set { tableView.editing = newValue }
    get { return tableView.editing }
  }

  public func setEditing(editing: Bool, animated: Bool) {
    tableView.setEditing(editing, animated: animated)
  }
}

// MARK: - Reloading the Table View
extension StatefulTableView {
  public func reloadData() {
    dispatch_async(dispatch_get_main_queue()) {
      self.tableView.reloadData()
    }
  }

  @available(iOS 3.0, *)
  public func reloadRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) {
    tableView.reloadRowsAtIndexPaths(indexPaths, withRowAnimation: animation)
  }

  @available(iOS 3.0, *)
  public func reloadSections(sections: NSIndexSet, withRowAnimation animation: UITableViewRowAnimation) {
    tableView.reloadSections(sections, withRowAnimation: animation)
  }

  @available(iOS 3.0, *)
  public func reloadSectionIndexTitles() {
    dispatch_async(dispatch_get_main_queue()) {
      self.tableView.reloadSectionIndexTitles()
    }
  }
}

// MARK: - Accessing Drawing Areas of the Table View
extension StatefulTableView {
  public func rectForSection(section: Int) -> CGRect {
    return tableView.rectForSection(section)
  }

  public func rectForRowRowAtIndexPath(indexPath: NSIndexPath) -> CGRect {
    return tableView.rectForRowAtIndexPath(indexPath)
  }

  public func rectForFooterInSection(section: Int) -> CGRect {
    return tableView.rectForFooterInSection(section)
  }

  public func rectFotHeaderInSection(section: Int) -> CGRect {
    return tableView.rectForHeaderInSection(section)
  }
}

// MARK: - Managing the Delegate and the Data Source
extension StatefulTableView {
  /**
   The object that acts as the data source of the table view.

   - Discussion: The data souce must adopt the `UITableViewDataSource` protocol. The data source is not retained.
   */
  public var dataSource: UITableViewDataSource? {
    set { tableView.dataSource = newValue }
    get { return tableView.dataSource }
  }

  /**
   The object that acts as the delegate of the table view.

   - Discussion: The delegate must adopt the `UITableViewDelegate` protocol. The delegate is not retained.
   */
  public var delegate: UITableViewDelegate? {
    set { tableView.delegate = newValue }
    get { return tableView.delegate }
  }
}

// MARK: - Configuring the Table Index
extension StatefulTableView {
  public var sectionIndexMinimumDisplayRowCount: Int {
    set { tableView.sectionIndexMinimumDisplayRowCount = newValue }
    get { return tableView.sectionIndexMinimumDisplayRowCount }
  }

  @available(iOS 6.0, *)
  public var sectionIndexColor: UIColor? {
    set { tableView.sectionIndexColor = newValue }
    get { return tableView.sectionIndexColor }
  }

  @available(iOS 7.0, *)
  public var sectionIndexBackgroundColor: UIColor? {
    set { tableView.sectionIndexBackgroundColor = newValue }
    get { return tableView.sectionIndexBackgroundColor }
  }

  @available(iOS 6.0, *)
  public var sectionIndexTrackingBackgroundColor: UIColor? {
    set { tableView.sectionIndexTrackingBackgroundColor = newValue }
    get { return tableView.sectionIndexTrackingBackgroundColor }
  }
}

// MARK: - Managing Focus
extension StatefulTableView {
  @available(iOS 9.0, *)
  public var remembersLastFocusedIndexPath: Bool {
    set { tableView.remembersLastFocusedIndexPath = newValue }
    get { return tableView.remembersLastFocusedIndexPath }
  }
}

// MARK: - Helpers
private extension StatefulTableView {
  private func pinView(view: UIView, toContainer container: UIView) {
    let attributes: [NSLayoutAttribute] = [.Top, .Bottom, .Leading, .Trailing]
    apply(attributes, ofView: view, toView: container)
  }

  private func centerView(view: UIView, inContainer container: UIView) {
    let attributes: [NSLayoutAttribute] = [.CenterX, .CenterY]
    apply(attributes, ofView: view, toView: container)
  }

  private func centerViewHorizontally(view: UIView, inContainer container: UIView) {
    apply([.CenterX], ofView: view, toView: container)
  }

  private func centerViewVertically(view: UIView, inContainer container: UIView) {
    apply([.CenterY], ofView: view, toView: container)
  }

  private func apply(attributes: [NSLayoutAttribute], ofView childView: UIView, toView containerView: UIView) {
    let constraints = attributes.map {
      return NSLayoutConstraint(item: childView, attribute: $0, relatedBy: .Equal,
        toItem: containerView, attribute: $0, multiplier: 1, constant: 0)
