在运行时获取类的类别详细信息?

编程入门 行业动态 更新时间:2024-10-24 08:23:21
本文介绍了在运行时获取类的类别详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Objective-C中,有没有一种方法可以在运行时列出特定类的类别?

In Objective-C, is there a way to list the categories on a particular class at runtime?

使用Objective-C运行时函数,我可以获得有关类和实例方法,类层次结构,实例变量等的详细信息,但似乎没有类别信息.

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.

看F脚本,我发现它不显示类别信息(实际上,它似乎根本不显示类别中的方法).另一方面,类转储会提取类别信息,但这是从二进制文件而不是在运行时提取的.

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.

在objc/runtime.h中提到struct objc_category,但这看起来是私有的.有没有受支持的方法?

There's a mention of struct objc_category in objc/runtime.h but this looks to be private. Is there a supported way?

推荐答案

来自 SDK文档中的"Objective-C编程语言" :

类别方法可以执行适当的类中定义的方法可以执行的任何操作.在运行时,没有任何区别.

Category methods can do anything that methods defined in the class proper can do. At runtime, there’s no difference.

现代的Objective-c(ios,10.5)已删除了对objc_category结构的支持,从而使该信息变得不透明.

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.

更多推荐

在运行时获取类的类别详细信息?

本文发布于:2023-11-15 23:22:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:详细信息   类别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!