iOS get property class

后端 未结 4 2228
粉色の甜心
粉色の甜心 2021-02-06 09:55

I\'m trying to get a list of all the properties of an unknown class and the class of every property. By the moment I get a list of all the properties of an object(I do it recurs

4条回答
  •  天命终不由人
    2021-02-06 10:41

    The following added to an NSObject category does the trick.

    - (Class) classForKeyPath:(NSString*)keyPath {
        Class class = 0;
    
        unsigned int n = 0;
        objc_property_t* properties = class_copyPropertyList(self.class, &n);
        for (unsigned int i=0; i

提交回复
热议问题