在运行时获取类的类别详细信息?
在 Objective-C 中,有没有办法在运行时列出特定类的类别?
通过 Objective-C 运行时函数,我可以获得类和实例方法、类层次结构、实例变量等的详细信息,但似乎不能获取类别信息。
查看 F-Script,我发现它不显示类别信息(实际上,它似乎根本不显示类别中的方法)。另一方面,类转储提取类别信息,但这是来自二进制文件,而不是在运行时。
objc/runtime.h 中提到了 struct objc_category,但这看起来是私有的。有支持的方式吗?
In Objective-C, is there a way to list the categories on a particular class at runtime?
With the Objective-C runtime functions I can obtain details for the class and instance methods, class hierarchy, instance variables, etc. but seemingly not the category information.
Looking at F-Script, I see that it doesn't display category information (indeed, it appears not to display methods from categories at all). On the other hand, class-dump extracts category information but this is from the binary and not at runtime.
There's a mention of struct objc_category in objc/runtime.h but this looks to be private. Is there a supported way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自” SDK 文档中的《Objective-C 编程语言》:
现代 Objective-C(ios,10.5)已删除对 objc_category 结构的支持,使得此信息不透明。
恐怕你无法获得你想要的信息。
from "The Objective-C Programming Language" in the SDK doc:
the support for objc_category struct has been removed with modern objective-c (ios, 10.5), making this information opaque.
I'm afraid you can't get the information you want.