以下代码产生错误No visible @interface for 'Bar'在以下实现的第二行声明选择器 'barMethod' -[Foo fooMethod]
:
// FooBar.m
#import "FooBar.h"
//////////////////////////////////
@implementation Foo
- (void)fooMethod {
Bar *bar = [Bar new];
[bar barMethod]; // Error: No visible @interface for 'Bar' declares the selector 'barMethod'
}
@end
//////////////////////////////////
@interface Bar ()
- (void)barMethod;
@end
@implementation Bar
- (void)barMethod {
// do something
}
@end
除了将类扩展移到实现之上(有时不是很方便)之外,还有什么方法可以-[Bar barMethod]
在 FooBar.m中转发声明?Bar
Foo