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

objective-c, objective-c-runtime

Solution

You have to import the runtime

#import <objc/runtime.h>

Problem

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

Original source