Property reflection in Objective C for iOS

前端 未结 1 872
梦如初夏
梦如初夏 2021-01-13 14:41

I would like to be able to use reflection on a classes within Objective C to determine what properties are available at run time.

I do something similar for classes

相关标签:
1条回答
  • 2021-01-13 14:54

    May be this will help:

    You can get the list of properties in a class using class_copyPropertyList

    objc_property_t * class_copyPropertyList(Class cls, unsigned int *outCount)
    

    and then from each property, you can get the property name using property_getName function and the property attributes using the property_getAttributes function (if you need to filter read-write properties).

    0 讨论(0)
提交回复
热议问题