在运行时获取类的类别详细信息? [英] Obtain details of categories on a class at runtime?

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

问题描述

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

推荐答案

来自:

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

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆