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

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

本文介绍了在运行时获取类的类别详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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?

推荐答案

来自:

现代的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.

这篇关于在运行时获取类的类别详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:57