如何枚举类的方法

发布于 2024-11-14 19:02:09 字数 304 浏览 2 评论 0原文

有没有办法枚举一个类的方法, 例如,我有一个如下定义的类:

@class Foo : NSObject
    -(void)doStuff1;
    -(void)doStuff2;
@end

我想知道是否有任何方法可以让我使用枚举方法访问方法“doStuff1”和“doStuff2”,甚至在我知道该类有两个方法之前。

我知道方法 [foo PerformSelector:@selector(doSutff1)] 但这不是我想要的。
请任何人告诉我怎么走,非常感谢。

Is there any way to enumerate methods of one class,
for example, I have one class defined like below:

@class Foo : NSObject
    -(void)doStuff1;
    -(void)doStuff2;
@end

And I was wondering if there is any way let me access the method "doStuff1" and "doStuff2" with enumerate methods, even before I know the class has two methods.

I know the method [foo performSelector:@selector(doSutff1)] but this is not I want.
Pls any guy tell me the way, thx so much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇色安年 2024-11-21 19:02:09

您使用运行时库...

class_copyMethodList

检查Apple文档 这里

You use the runtime library...

class_copyMethodList

Check the Apple docs here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文