Skip to content

Instantly share code, notes, and snippets.

@pranjalsatija
Created February 8, 2020 00:07
Show Gist options
  • Save pranjalsatija/d6b949bf649e61b809e309353bcaaf83 to your computer and use it in GitHub Desktop.
Save pranjalsatija/d6b949bf649e61b809e309353bcaaf83 to your computer and use it in GitHub Desktop.
An extension on UITableView to add support for table view descriptors.
extension UITableView {
static private let snapshotKey = "snapshot"
var descriptor: UITableViewDescriptor? {
get { objc_getAssociatedObject(self, Self.snapshotKey) as? UITableViewDescriptor }
set {
objc_setAssociatedObject(self, Self.snapshotKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
delegate = newValue
newValue?.tableView = self
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment