Created
November 6, 2020 11:39
-
-
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
This file contains hidden or 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
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