Created
February 8, 2020 00:07
-
-
Save pranjalsatija/d6b949bf649e61b809e309353bcaaf83 to your computer and use it in GitHub Desktop.
An extension on UITableView to add support for table view descriptors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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