Created
November 7, 2013 17:42
-
-
Save hcrub/7358702 to your computer and use it in GitHub Desktop.
Objective C Runtime's class_addIvar adding a new instance variable to a class
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
/** | |
* class_addIvar | |
* Adds a new instance variable to a class. | |
* | |
* BOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types) | |
* | |
* Return Value | |
* YES if the instance variable was added successfully, otherwise NO. | |
**/ | |
- (BOOL)addInstanceVariable | |
{ | |
return class_addIvar(subClass, "varName", sizeof(id), rint(log2(sizeof(id))), @encode(id));; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment