Created
February 12, 2013 17:10
-
-
Save samkaufman/4771420 to your computer and use it in GitHub Desktop.
An Xcode snippet implementing a category property that wraps an associated object. (Instance variables in categories, basically.)
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
| static const void *<#Capitalized name#>AssociationKey; | |
| - (<#Type#> *)<#Name#> { | |
| return objc_getAssociatedObject(self, &<#Capitalized name#>AssociationKey); | |
| } | |
| - (void)set<#Name#>:(<#Type#> *)newObject { | |
| objc_setAssociatedObject(self, &<#Capitalized name#>AssociationKey, newObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment