Skip to content

Instantly share code, notes, and snippets.

@joslinm
Created April 8, 2013 23:19
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 joslinm/5341452 to your computer and use it in GitHub Desktop.
Save joslinm/5341452 to your computer and use it in GitHub Desktop.
basic objc/runtime usage
#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