Skip to content

Instantly share code, notes, and snippets.

@josipbernat
Created November 6, 2020 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josipbernat/f346b0b3f75f7e238a2214735a5c5a90 to your computer and use it in GitHub Desktop.
Save josipbernat/f346b0b3f75f7e238a2214735a5c5a90 to your computer and use it in GitHub Desktop.
When regular Int tag isn't sufficient and you need string representation of UIView identifier
fileprivate var StringIdentifierHandle: UInt8 = 2
extension UIView {
var stringIdentifier: String? {
get {
return objc_getAssociatedObject(self, &StringIdentifierHandle) as? String
}
set {
objc_setAssociatedObject(self, &StringIdentifierHandle, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment