Created
July 11, 2013 19:49
-
-
Save woolsweater/5978625 to your computer and use it in GitHub Desktop.
Getting metadata for property in category.
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
| #import <Foundation/Foundation.h> | |
| #import <objc/runtime.h> | |
| @interface Rigby : NSObject | |
| @end | |
| @implementation Rigby | |
| @end | |
| @interface Rigby (Eleanor) | |
| @property (nonatomic, copy) NSString * jarByTheDoor; | |
| @property (nonatomic, copy) NSString * riceInTheChurch; | |
| @end | |
| @implementation Rigby (Eleanor) | |
| @dynamic jarByTheDoor; | |
| - (NSString *)riceInTheChurch | |
| { | |
| return @""; | |
| } | |
| - (void)setRiceInTheChurch:(NSString *)riceInTheChurch | |
| { | |
| return; | |
| } | |
| @end | |
| int main(int argc, const char * argv[]) | |
| { | |
| @autoreleasepool { | |
| objc_property_t jar = class_getProperty([Rigby class], "jarByTheDoor"); | |
| NSLog(@"%s", property_getAttributes(jar)); | |
| objc_property_t rice = class_getProperty([Rigby class], "riceInTheChurch"); | |
| NSLog(@"%s", property_getAttributes(rice)); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment