是否可以通过编程方式确定类具有哪些属性?
是否可以通过编程方式确定类具有哪些属性?我想查看类(或子类)定义了哪些属性。有人告诉我这与运行时内省有关。我找到了这篇文章,但它似乎只是冰山一角。
那么,是否可以通过编程方式确定一个类具有哪些属性?如何?
编辑:
我使用的是 iOS,而不是 Mac OS X。我需要导入哪些标头?
Is it possible to determine what properties a class has programmatically? I want to see what properties a class (or subclass) has defined. I'm told this has to do with something called runtime introspection. I've found this article, but it seems to be just the tip of the iceberg.
So, is it possible to determine what properties a class has programmatically? How?
Edit:
I'm working on iOS, not Mac OS X. What headers do I need to import?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Objective-C 运行时编程指南包括一个部分关于列出属性。实际获取列表的相关片段是:
然后,您使用运行时属性函数来获取有关列表中每个属性的任何信息。
The Objective-C Runtime Programming Guide includes a section about listing properties. The relevant snippet that actually gets the list is:
Then you use the runtime property functions to get whatever information you want about each property in the list.