Created
April 8, 2013 23:19
-
-
Save joslinm/5341452 to your computer and use it in GitHub Desktop.
basic objc/runtime usage
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
#define KEY @"key" | |
// Set vaulue as a property of obj | |
id obj = [NSObject alloc] init] | |
id value = [[NSObject alloc] init] | |
objc_setAssociatedObject(obj, KEY, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
// Get that same value from object | |
id value = objc_getAssociatedObject(obj, KEY) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment