Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objective-c runtime error "Use of undeclared identifier 'objc_property_t'"

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!.

like image 930
Rubs Avatar asked Jul 12 '12 17:07

Rubs


1 Answers

You have to import the runtime

#import <objc/runtime.h> 
like image 125
jerrylroberts Avatar answered Oct 05 '22 14:10

jerrylroberts