I'm trying to get the properties from my class using obj-c runtime approach I found on the answers from here, however I'm getting a lot of warnings/error when coding, do I need to import the library or make something in order to have the obj-c runtime functions available?
objc_property_t *properties = class_copyPropertyList([self class], &outCount);
Warning: "Implicit declaration of function 'class_copyPropertyList' is invalid in C99 Error: Use of undeclared identifier 'objc_property_t'
This is the whole chunk that I've copied:
unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList([self class], &outCount); for (i = 0; i < outCount; i++) { objc_property_t property = properties[i]; NSString *propertyName = [[NSString alloc] initWithCString:property_getName(property)]; id propertyValue = [self valueForKey:(NSString *)propertyName]; if (propertyValue) [props setObject:propertyValue forKey:propertyName]; } free(properties);
Thanks in advance!.
You have to import the runtime
#import <objc/runtime.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With