【发布时间】:2011-11-28 08:49:20
【问题描述】:
我真的对这个问题感到困惑。我需要做的是在我的项目中使用一些 obj-c 运行时特性。这是我的 .m 文件中的简单代码:
#import "Base.h"
#import <objc/runtime.h>
@implementation Base
- (void)someMethod {
NSUInteger numberMethods = 0;
Method *classMethods = class_copyMethodList([self class], &numberMethods);
for (int i = 0; i < numberMethods; i ++) {
classMethods[i]->method_name; //incomplete definition of type "struct objc_method"
}
@end
我收到以下错误:“struct objc_method”类型的定义不完整。在检查了一些 objc/runtime.h 文件后,我发现了这样的内容:
一些代码...
typedef struct objc_method *Method;
...一些代码...
struct objc_method {
SEL method_name OBJC2_UNAVAILABLE;
char *method_types OBJC2_UNAVAILABLE;
IMP method_imp OBJC2_UNAVAILABLE;
}
这类似于前向声明问题,还是其他问题?
【问题讨论】:
标签: objective-c ios runtime forward-declaration